[R] debugging functions in R
Liviu Andronic
landronimirc at gmail.com
Wed Aug 24 16:29:32 CEST 2011
On Wed, Aug 24, 2011 at 4:20 PM, Eran Eidinger <eran at taykey.com> wrote:
> Hi,
>
> I am not sure if this is the right list to ask this question (though I did
> not find a more appropriate one).
> I've started using R a month ago, and small scripts work fine. However, when
> I start writing more complex code, it gets messy.
>
> 1. Is there any way to debug "normally", with breakpoints?
>
> fortune('browser')
My solution when I run into mysteries like this is to put 'browser()' in the
function just before or after the line of interest. The magnitude and direction
of my stupidity usually become clear quickly.
-- Patrick Burns
R-help (February 2006)
Use browser() to inspect the environment and execute the code one step
at a time.
Liviu
>2. I am using the Eclipse plugin (StatET), and tried JGR(). Is there an IDE
> that enables breakpoints?
> 3. Is there an equivalent to "include" in other programming languages? So
> many functions in one file are very messy. I would like to break it to
> several files.
> 4. Any way to create a "local" context of variables inside a function?
> Otherwise I have to be careful to give different names inside functions, to
> those in the workspace.
>
> I should point that I am a long time Matlab user and am probably expecting
> some things that don't necessarily exist in R...
>
> I know it's a lot, if there is a more appropriate forum to ask these, please
> point me in that direction.
>
> Thanks,
> Eran.
>
> *
>
> *
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail
More information about the R-help
mailing list