[R] Get object name inside lapply

Rolf Turner r.turner at auckland.ac.nz
Fri Feb 26 00:19:47 CET 2016

On 26/02/16 11:37, Huzefa Khalil wrote:
> If you want the object names, you should use lapply over the names:
> lapply(names(c), function(x) {c[[x]]})

This makes no sense at all to me; you get the same result simply by 
typing "c".

If the OP's message is interpreted literally, all he needs to do is type 
"names(c)".  But this may not be what he *really* wants.  It's hard to tell.

Note that "c" is *not* a good name for a data set, since it is the name 
of an (important) base function.


Rolf Turner

Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

More information about the R-help mailing list