[R] A way to list only variables or functions?

Shin, Daehyok sdhyok at email.unc.edu
Mon Jun 21 15:53:35 CEST 2004


Glad to know useful functions.
How about adding lsv.str function to list only variables bound to values?
In my opinion, we are more interested in values than functions in the
process of data analysis.

In addition, the simple solution of Grothendieck to display only names of
objects has its own practical value.

Daehyok Shin

> -----Original Message-----
> From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk]
> Sent: Sunday, June 20, 2004 PM 12:03
> To: Shin, Daehyok
> Cc: r-help at stat.math.ethz.ch
> Subject: RE: [R] A way to list only variables or functions?
>
>
> On Sun, 20 Jun 2004, Shin, Daehyok wrote:
>
> > Neat! Thanks.
>
> Note that these are not correct, as the get is not done from the
> correct environment.  The function ls.str I pointed you to is correct.
>
> > How about incorporating this support into standard commands, ls() or
> > objects()?
>
> Well, there already is ls[f].str.
>
> > Daehyok Shin (Peter)
> >
> > > -----Original Message-----
> > > From: Gabor Grothendieck [mailto:ggrothendieck at myway.COM]
> > > Sent: Sunday, June 20, 2004 AM 10:06
> > > To: sdhyok at email.unc.edu; r-help at stat.math.ethz.ch
> > > Subject: RE: [R] A way to list only variables or functions?
> > >
> > >
> > >
> > >
> > > These two functions will list the functions and variables
> > > respectively:
> > >
> > > ls.funs <-
> > > function(env=sys.frame(-1))unlist(lapply(ls(env=env),function(x)if
> > > (is.function(get(x)))x))
> > >
> > > ls.vars <-
> > > function(env=sys.frame(-1))unlist(lapply(ls(env=env),function(x)if
> > > (!is.function(get(x)))x))
> > >
> > >
> > > To use:
> > >
> > > ls.funs()
> > > ls.vars()
> > >
> > >
> > > Date:   Sat, 19 Jun 2004 22:59:57 -0400
> > > From:   Shin <sdhyok at email.unc.edu>
> > > To:   R Help <r-help at stat.math.ethz.ch>
> > > Subject:   [R] A way to list only variables or functions?
> > >
> > >
> > > I am curious if there is any way to list only variables or
> functions in
> > > current environment, rather than listing all objects? Thanks.
> > >
> > > --
> > > Daehyok Shin (Peter)
> > > Geography Department
> > > Univ. of North Carolina-Chapel Hill
> > >
> > >
> > >
> > > _______________________________________________
> > > No banners. No pop-ups. No kidding.
> >
> > >
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
>
>

--
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list