[R] Constructing lists (yet, again)
roger koenker
rkoenker at uiuc.edu
Thu Jul 23 16:19:47 CEST 2009
This is an attempt to rescue an old R-help question that apparently
received
no response from the oblivion of collective silence, and besides I'm
also
curious about the answer
> From: Griffith Feeney (gfeeney at hawaii.edu)
> Date: Fri 28 Jan 2000 - 07:48:45 EST wrote (to R-help)
> Constructing lists with
>
> list(name1=name1, name2=name2, ...)
>
> is tedious when there are many objects and names are long. Is there
> an R
> function that takes a character vector of object names as an
> argument and
> returns a list with each objected tagged by its name?
>
The idiom
lapply(ls(pat = "^name"), function(x) eval(as.name(x)))
makes the list, but (ironically) doesn't assign the names to the
components.
url: www.econ.uiuc.edu/~roger Roger Koenker
email rkoenker at uiuc.edu Department of Economics
vox: 217-333-4558 University of Illinois
fax: 217-244-6678 Urbana, IL 61801
More information about the R-help
mailing list