[R] variable length lisin in data frame

arun smartpink111 at yahoo.com
Sat May 10 15:51:11 CEST 2014


Hi,
Try:
 dat <- data.frame(id=1:4, contacts_list=I(list(3:4,c(1,3,4), c(4,2,1), 1)), `number of contacts`=c(2,3,3,1),check.names=FALSE)

attr(dat$contacts_list,"class") <- NULL #if needed
 dat
A.K.



Dear Group,
I have data like the following

id   contacts_list   number of contacts
---------------------------------------------------
1   3 4                               2
2   1 3 4                            3
3    4 2 1                           3
4    1                                1
------------------------------------------------------


can you kindly please sugest a data type in R to use for it?
i thought about data frame that consists of a  list element. but  lists are not in  the same length, any  solutions?
thanks in advance
RAE 




More information about the R-help mailing list