[R] Dynamic string as element name in a list

Paul Lemmens paul.lemmens at gmail.com
Thu Mar 27 14:38:04 CET 2008


Dear all,

I have a piece of code along the lines of

f <- function(x) {
 clipname <- "LK"  # but is in real determined based on info in data.frame x
 # other manipulations
 return( list(clipname=list(....)))
}

My intention is to do

out <- f(dat)

and then (in this example) having/getting

out$LK

which is a list in itself.


Of course, it doesn't work like this, but having tried all kinds of
combinations of eval(), parse(), substitute(), and friends I was
unable to get the contents of clipname as the element name of the list
that I return in f().

Is this possible to do so at all and if so, what am I missing?


Kind regards,
Paul Lemmens



More information about the R-help mailing list