[R] how to make list() return a list of *named* elements

Berwin A Turlach berwin at maths.uwa.edu.au
Mon Oct 4 13:51:10 CEST 2010


On Mon, 4 Oct 2010 19:45:23 +0800
Berwin A Turlach <berwin at maths.uwa.edu.au> wrote:

Mmh,

> R> my.return <- function (vector.of.variable.names) {
>   sapply(vector.of.variable.names, function(x) list(get(x)))
> }

make that:

R> my.return <- function (vector.of.variable.names) {  
     sapply(vector.of.variable.names, function(x) get(x))
   }

Cheers,

	Berwin



More information about the R-help mailing list