[R] R: to view the memory - and a quiz

Martin Maechler maechler at stat.math.ethz.ch
Wed Sep 12 09:13:33 CEST 2007


>>>>>   <Sumit.Gupta at ubs.com>
>>>>>     on Wed, 12 Sep 2007 03:01:43 +0100 writes:

    > Hello, I am wondering if it is possible to view what
    > variables and vairable values are stored in the R
    > memory. This to enable debugging of R-scripts I write.

In simple to moderately small examples, I'd recommend (my own creation)

    ls.str()

I've lately started to use it also from inside a function,
i.e. after using debug(.) or after options(error = recover) and
a jump "inside a function" to explore the local variables of the
function I'm debugging. In that case, I use

   ls.str(envir = environment())

something which I've been using so frequently lately, that I had
started wondering a bit if some nice (short and simple!)
enhancement to ls.str() was possible which would make
   ls.str()  {without specifying  'envir = environment()'}
automagically use the "proper" environment when run inside a function.
Since then, I had never found the time to follow the idea,
we now have a quiz:  What's the best solution to the above problem?

Martin



More information about the R-help mailing list