Ted Harding asked:
>
> I can of course get these individually with, for the 5th one for
> instance,
> 
>   C.W[[5]]$level
>   C.W[[5]]$x
>   C.W[[5]]$y
> 
> But I can't see how to obtain, in one line and without running
> a nasty loop, to get all the levels at once!
> 
> In other words, I'm looking for an expression which will return
> the vector
> 
>   c(C.W[[1]]$level,C.W[[2]]$level,...,C.W[[28]]$level)
> 
Hmmmm...

Did you try this?

# reproducible example
C.W <- list(list(level = 1, x = 2), list(level = 2, y = 3), list(level = 10, 
z = 4))
sapply(C.W, function(x) x$level)

Alberto Monteiro

______________________________________________
R-help@r-project.org 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.

Reply via email to