[R] From FAQ 7.21 to a command like apply(sapply(list(f1,f2,f3),is.na),2,sum)
Heinz Tuechler
tuechler at gmx.at
Wed Mar 30 00:40:12 CEST 2005
Dear all,
Last December there was a thread regarding the famous FAQ 7.21 "How can I
turn a string into a variable?" and asking what people want to do with
these strings.
My, certainly trivial application would be as follows:
Assume I have a data.frame containing besides others also the columns f1,
f2, ..., fn and I want to create a command like:
apply(sapply(list(f1,f2,f3),is.na),2,sum)
or
summary(cbind(f1,f2,f3))
Can I start from paste('f',1:3,sep='') to arrive at the abovementioned
command?
I tried get, parse, as.name, eval in diverse combinations but did not reach
a solution.
More generally my question is, how can I produce a "list" of variables like
x1 to xn in a convenient way within a command.
I am quite sure that this has been answered several times, but I did not
find one of these answers. So I welcome any hint, where to look.
Heinz Tüchler
More information about the R-help
mailing list