Re: [R] reshape data frame when one column has unequal number of entries

2015-04-23 Thread Dimitri Liakhovitski
Thank you very much, everybody! On Thu, Apr 23, 2015 at 10:38 AM, Duncan Mackay wrote: > Hi Dimitri > > here is a quick crude way (needs some polishing) > > data.frame(a = rep(x$a,sapply(sapply(x$b, strsplit, ", "), length)), b= > unlist(sapply(x$b, strsplit, ", "))) > > Duncan > > Duncan Mackay

Re: [R] reshape data frame when one column has unequal number of entries

2015-04-23 Thread PIKAL Petr
Hi I am not sure if this is more efficient than some loop I just gave your data another column names. > names(x)<-c("one", "two") > x one two 1 1 a, b, c 2 2d, e 3 3 f > s<-(strsplit(x$two, ",")) > s [[1]] [1] "a" " b" " c" [[2]] [1] "d" " e" [[3]] [1] "f" > first<-rep

Re: [R] reshape data frame when one column has unequal number of entries

2015-04-23 Thread Duncan Mackay
Hi Dimitri here is a quick crude way (needs some polishing) data.frame(a = rep(x$a,sapply(sapply(x$b, strsplit, ", "), length)), b= unlist(sapply(x$b, strsplit, ", "))) Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mac...@n

Re: [R] reshape data frame

2013-11-18 Thread tsippel
Thanks, that seems to work. On Fri, Nov 15, 2013 at 10:26 PM, arun kirshna [via R] < ml-node+s789695n4680556...@n4.nabble.com> wrote: > Hi, > > Try: > var1 <- load("reshape_data.frame.RData") > ##It is better not to name the objects with function names. > dat1 <- data > reshape1 <- reshape > na

Re: [R] reshape data frame

2013-11-15 Thread arun
Hi, Try: var1 <- load("reshape_data.frame.RData") ##It is better not to name the objects with function names. dat1 <- data  reshape1 <- reshape names(dat1)[grep("X\\d+",names(dat1))] <- gsub("[[:alpha:]]","X_",names(dat1)[grep("X\\d+",names(dat1))]) res1 <- reshape(dat1,direction="long",varying=7