Debug
debug(myfunction)
after the error appears try traceback to explore the errors
traceback()
Set Breakpoint
myFunction <- emacs(myFunction)
add browser() at position of breakpoint (exit browser with Q)
http://www.stats.uwo.ca/faculty/murdoch/software/debuggingR/debug.shtml