[R] Debugging a program written in the R language

Michael H. Prager Mike.Prager at noaa.gov
Wed Mar 8 22:34:12 CET 2006


 From the R prompt, try typing

?source

A good editor, specialized for working with R source on Windows, is Tinn-R.



on 3/8/2006 4:12 PM Thomas L Jones said the following:
> >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
>   

-- 

Michael Prager, Ph.D.
Population Dynamics Team, NMFS SE Fisheries Science Center
NOAA Center for Coastal Fisheries and Habitat Research
Beaufort, North Carolina  28516
http://shrimp.ccfhrb.noaa.gov/~mprager/
Opinions expressed are personal, not official.  No
government endorsement of any product is made or implied.




More information about the R-help mailing list