Re: [R] Count data with several numbers separated by commas

2009-04-16 Thread Bill.Venables
; table(x1_all) x1_all 1 2 3 4 5 9 6 2 2 8 > Bill Venables http://www.cmis.csiro.au/bill.venables/ -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Xiyan Lon Sent: Thursday, 16 April 2009 4:04 PM To: r-h...@stat.math.ethz.c

Re: [R] Count data with several numbers separated by commas

2009-04-15 Thread Simon Blomberg
Here's a solution, though it may be overcomplicated. I assume the data frame is called "dat": vec <- unlist(lapply(strsplit(dat$x1, ","), function (x) summary(as.factor(x > table(names(vec)) 1 2 3 4 5 9 6 2 2 8 Cheers, Simon. On Thu, 2009-04-16 at 13:03 +0700, Xiyan Lon wrote: > Dear a

[R] Count data with several numbers separated by commas

2009-04-15 Thread Xiyan Lon
Dear all, I have a data file with 3 variables (x1, x2, x3) where variable x1 have data that consists of several numbers separated by commas. id name x1 x2x3 aa1011,4,52 1 aa1021,2,51 2 aa1031,2,51 1 aa1041,2,31 2 aa1051,5 2 2