Re: [R] data.frame with variable-length list

2013-03-08 Thread William Dunlap
Note that c(list(1,2,3), list(4, 5,6), list(7,8,9, 10)) is identical to list(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) You want either list(list(1,2,3), list(4,5,6), list(7,8,9,10)) # list of 3 lists of numeric scalars or list(c(1,2,3), c(4,5,6), c(7,8,9,10)) # list of 3 numeric vectors In any ca

Re: [R] data.frame with variable-length list

2013-03-08 Thread arun
Hi, You could also try:   df1<-data.frame(name=c("a","b","c"),type=c(1,2,3),rtn=as.array(list(1:3,4:6,7:10))) A.K. - Original Message - From: Kevin Zembower To: r-help@r-project.org Cc: Sent: Friday, March 8, 2013 7:49 PM Subject: [R] data.frame with variable-length list Hello, I'm

Re: [R] data.frame with variable-length list

2013-03-08 Thread arun
HI, Try this:   df<-data.frame(name=c("a","b","c"),type=c(1,2,3),rtn=do.call(cbind,list(list(1:3,4:6,7:10  str(df) #'data.frame':    3 obs. of  3 variables: # $ name: Factor w/ 3 levels "a","b","c": 1 2 3 # $ type: num  1 2 3 # $ rtn :List of 3  # ..$ : int  1 2 3   #..$ : int  4 5 6   .#.$ : i