Dear R helper,
I wonder whether there is a quick way to extract some elements for a list.
for a vector we can do the following
vec <- seq(3)
names(vec) <- LETTERS[1:3]
vec[c(1,3)]
vec[c('A','C')]
But for a list,
test.l <- list(c(1,3),array(NA,c(1,2)),array(0,c(2,3)))
names(test.l)<-LETTERS[1:3]
The following does not work. is there some command (I was thinking of
do.call) that can do the job?
test.l[[c('A','B')]]
test.l[[c(1,3)]]
do.call('[',c(test.l,c(1,3)))
do.call('[[',c(test.l,c(1,3)))
do.call('[',c(test.l,c('A','C')))
do.call('[[',c(test.l,c('A','C')))
Thanks in advance.
-Sean
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.