[R] group vectors of different length
vito muggeo
vito.muggeo at giustizia.it
Tue Mar 19 09:37:08 CET 2002
The following toy-code could help you:
> a<-list()
> is.list(a)
[1] TRUE
> x1<-rnorm(5)
> x2<-rnorm(11)
> x3<-rnorm(100)
> length(a)
[1] 0
> a[[length(a)+1]]<-x1
> a[[length(a)+1]]<-x2
> a[[length(a)+1]]<-x3
> length(a)
[1] 3
> sapply(a,length)
[1] 5 11 100
So you can call each vector with integer indices, a[[1]], a[[2]], and so on.
best,
vito
----- Original Message -----
From: "Francisco J Molina" <FJMolina at lbl.gov>
To: "r-help" <r-help at stat.math.ethz.ch>
Sent: Tuesday, March 19, 2002 5:21 AM
Subject: [R] group vectors of different length
> If I have several vectors of different length. Is there any way to group
> them in R and call them with an integer (and index)?
> Let us assume that the number of vectors is not known before I run the
> script.
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-
> 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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list