[R] How can I create a vector of vector?

rkevinburton at charter.net rkevinburton at charter.net
Mon Aug 11 17:23:54 CEST 2008


I have a slightly different question. Rather than build the list all at once I would like to know how to append. Essentially ending up with a list of lists. Something like:

x <- c(31,2,3)
a <- list(list(x))
x <- c(42,3,5)
a <- append(a, list(x))

Can it be done this way? So now the length(a) is 2 for the above and a[1] is the list (31,2,3)?

Kevin

---- stephen sefick <ssefick at gmail.com> wrote: 
> is this what you want?
> 
> x <- c(31,2,3)
> y <- c(1,2,5,34,5656)
> z <- c(211,3243,5,343,3)
> a <- list(x,y,z)
> 
> On Fri, Aug 8, 2008 at 1:59 PM, Jim <chunchiliu at gmail.com> 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)
> >
> > Jim Liu
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> 
> 
> 
> -- 
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods. We are mammals, and have not exhausted the
> annoying little problems of being mammals.
> 
> 	-K. Mullis
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list