[R] Lists to vectors...

Renaud Lancelot lancelot at sentoo.sn
Thu Sep 26 20:13:41 CEST 2002


or even

> unlist(list(1:3, 5:9, 3:7))
 [1] 1 2 3 5 6 7 8 9 3 4 5 6 7

Best,

Renaud

kjetil halvorsen wrote:
> 
> > test <- list(1:3, 5:9, 3:7)
> > test
> [[1]]
> [1] 1 2 3
> 
> [[2]]
> [1] 5 6 7 8 9
> 
> [[3]]
> [1] 3 4 5 6 7
> 
> > do.call("c", test)
>  [1] 1 2 3 5 6 7 8 9 3 4 5 6 7
> 
> Kjetil Halvorsen
> 
> Kevin Karty wrote:
> >
> > Hello, can anyone answer:
> >
> > Is there a fast, vectorized way to convert a list of integer vectors, in
> > which each vector has different length, to a single vector that is
> > simply the concatenation of all the member vectors?  Or does one have to
> > loop over the list and concatenate everything?
> >
> > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> > 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
> > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
Dr Renaud Lancelot, vétérinaire
CIRAD, Département Elevage et Médecine Vétérinaire (CIRAD-Emvt)
Programme Productions Animales
http://www.cirad.fr/presentation/programmes/prod-ani.shtml (Français)
http://www.cirad.fr/presentation/en/program-eng/prod-ani.shtml (English)

ISRA-LNERV                      tel    +221 832 49 02
BP 2057 Dakar-Hann              fax    +221 821 18 79 (CIRAD)
Senegal                         e-mail renaud.lancelot at cirad.fr
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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