[R] Debugging a program written in the R language

Ferdinand Alimadhi falimadhi at iq.harvard.edu
Wed Mar 8 22:38:37 CET 2006


The simplest way:

1. Write the program using your favorite text editor and save it i.e. 
c:/try.R
2. Open R and write source("c:/try.R")

See "source" help (?source) for more information

I would recommend that, even you are a windows user, you use the emacs 
package for statistic (ESS). There are also other "IDE"s available.
In this respect I actually do not see any difference between R and other 
programming languages

HTH



Thomas L Jones wrote:

>>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 at 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
>
>  
>


-- 
Ferdinand Alimadhi
Programmer / Analyst
Harvard University
The Institute for Quantitative Social Science
(617) 496-0187
falimadhi at iq.harvard.edu
www.iq.harvard.edu




More information about the R-help mailing list