[R] define a list with names as variables

Giovanni Gherdovich g.gherdovich at gmail.com
Fri Aug 4 10:56:47 CEST 2017


Hello,

I'm having troubles defining a list where names are variables (of type
character). Like this, which gives "foo" instead of "world" (the way I
meant it is that "world" is the value of the variable foo). Any hint?

> f <- function(foo, bar) { list(foo = bar) }
> x <- f("hello", "world")
> names(x)
[1] "foo"


Thanks,
Giovanni



More information about the R-help mailing list