[R] list of lists
Thomas Lumley
tlumley at u.washington.edu
Mon Jun 17 17:24:56 CEST 2002
On Mon, 17 Jun 2002, Juan Ramon Gonzalez wrote:
> Hi R-users
>
> I have a list with 19 elments. This elements are a new list of 2 elements,
> for example:
>
> times<-
> [[1]]
> [[1]]$time
> 11 10
> 147 206 30
>
> [[1]]$n
> [1] 3
>
> .......
>
> [[19]]
> [[19]]$time
> 96 96 96 94 98
> 78 78 78 147 100 4
>
> [[19]]$n
> [1] 6
>
> Does anyone know how obtain a vector with the elements $time as quick as
> possible (no loops)?
>
assuming you want them all concatenated
unlist(lapply(times, function(x) x$time))
If you have lots of short lists like this one it may not be much faster
than a loop, but with long lists it should be.
-thomas
Thomas Lumley Asst. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list