[R] Debugging a program written in the R language
    Robert Burrows 
    rbb at nebiometrics.com
       
    Thu Mar  9 15:12:59 CET 2006
    
    
  
Thomas,
This is what I use for writing R programs. I use it with Linux but 
adapting it for Windows shouldn't be that much of a problem for us MIT 
guys.
In ~/.Rprofile (so it gets loaded every time I start R) I have
myedit <- function(object) {
     system("if [ ! -d $HOME/stat-misc/Rsrc ]; then mkdir $HOME/stat-misc/Rsrc; fi")
     system(paste("vim $HOME/stat-misc/Rsrc/",object,".R",sep=""))
     source(paste("~/stat-misc/Rsrc/",object,".R",sep=""))
}
To write a program called 'functionName' I do, within R, 
"myedit('functionName')". This opens up an editor, vim in my case, for 
writing the function and saves the result in the ~/stat-misc/Rsrc 
directory and in the current R session. I can now repeat 
"myedit('functionName')" until I finally get it right. The function is 
also accessible with myedit() from any other R session at any time.
Good luck,
Robert Burrows, PhD
New England Biometrics
rbb at nebiometrics.com
    
    
More information about the R-help
mailing list