[R] nesting vectors in a dataframe

Damon Wischik djw1005 at cam.ac.uk
Wed Mar 3 19:41:57 CET 2004


Steven Lacey wrote:
> I want to create a dataframe where one of the columns does not hold
> individual elements, but a vector instead. 
> ...
> However, if my dataframe does not already exist, then I cannot create a
> dataframe with vectors using the following syntax:
> data.frame(x1=list(c(5,6,7),c(8,9,10)))

data.frame(x1=I(list(c(5,6,7),c(8,9,10))))

will work. You need to tell R to keep the list AsIs, using the AsIs
function I(.)

Damon.




More information about the R-help mailing list