[R] Simple extraction of level,x,y from contourLines()
Alberto Monteiro
albmont at centroin.com.br
Thu Oct 22 21:20:35 CEST 2009
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
More information about the R-help
mailing list