Firstly, some corrections:

- It's best to write code as functions in R, just like most sensible
languages.  You can then debug the functions.

- (X)Emacs has versions for Windows.  Prof. John Fox has kindly made
available some instructions on how Xemacs/ESS can be set up on Windows.

Now, Roger Peng has kindly made available a note on debugging R code:
http://www.biostat.jhsph.edu/~rpeng/docs/R-debug-tools.pdf

Also, for compiled code linked to R, Duncan Murdoch's notes will be helpful:
http://www.stats.uwo.ca/faculty/murdoch/software/debuggingR/

Finally, there's a `debug' package on CRAN with a R News article describing
it.

Andy

From: Thomas L Jones
> 
> >From Tom:
> 
> The subject is debugging a program written in the R language,under 
> Windows. (Sorry, but I do not know either the Apple OS or *nix.) A 
> computer program will usually not work on the first try, if only 
> because of the risk of typos. Instead, it must be debugged. Roughly, 
> here is the sequence:
> 
> (1) One codes a program using the R language,  and stores it on the 
> hard drive, using some particular editor.
> 
> (2) The program is fed to the R software, together with test data, 
> etc.
> 
> (3) A test computation is run and bugs are spotted.
> 
> (4) The program is corrected, using an editor, and the 
> revised version 
> is stored on the hard drive.
> 
> (5) The sequence goes back to step (2) and is repeated until the 
> program hopefully works.
> 
> Unfortunately, the documentation doesn't really explain how to do all 
> of this, or if it is explained in the documentation, I can't find it.
> 
> Reading between the lines a bit, I infer that you are supposed to be 
> able to use something called a History file, then sort of work 
> backward in the code and make corrections. I never got it to work for 
> me. Also, it is unclear how you would handle code entered six 
> weeks or 
> six months ago.
> 
> That is the bad news; the good news is that some kind soul told me 
> about a key trick; prepare the program in Windows text format (.txt) 
> and copy it and paste it into the console. The program will now run 
> from a user-defined "wrapper" or "driver" function.
> 
> I am aware that there is an editor called Emacs which you can use if 
> you are a member of the *nix community, which I am not.
> 
> Question: How are you -supposed- to debug a program which you have 
> written in the R language?
> 
> Tom
> Thomas L. Jones, Ph.D., Computer Science
> 
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to