[R] How can I create a vector of vector?
Duncan Murdoch
murdoch at stats.uwo.ca
Fri Aug 8 21:25:04 CEST 2008
On 8/8/2008 1:59 PM, Jim wrote:
> Dear All,
>
> How can I create a vector of vector in R?
> for example, I would input the data as follows:
> x[1] <- c(31,2,3)
> x[2] <- c(1,2,5,34,5656)
> x[3] <- c(211,3243,5,343,3)
x <- list()
x[[1]] <- c(31,2,3)
x[[2]] <- c(1,2,5,34,5656)
x[[3]] <- c(211,3243,5,343,3)
Note the double brackets: x[[1]] is the thing stored in the first
element of x; x[1] would be a length-1 list containing only the first
element from the list x.
Duncan Murdoch
More information about the R-help
mailing list