[R] Can a data.frame column contain lists/arrays?

Christian Convey christian.convey at gmail.com
Tue Feb 13 05:29:14 CET 2007


I'd like to have a data.frame structured something like the following:

d <- data.frame (
   x=list( c(1,2), c(5,2), c(9,1) ),
   y=c( 1, -1, -1)
)

The reason is this: 'd' is the training data for a machine learning
algorithm.  d$x is the independent data, and d$y is the dependent
data.

In general my machine learning code will work where each element of
d$x is a vector of one or more real numbers.  So for instance, the
same code should work when d$x[1] = 42, or when d$x[1] = (42, 3, 5).
All that matters is that all element within d$x are lists/vectors of
the same length.

Does anyone know if/how I can get a data.frame set up like that?

Thanks,
Christian



More information about the R-help mailing list