Re: [R] vectorizing problem

2010-10-04 Thread Gabor Grothendieck
On Mon, Oct 4, 2010 at 2:39 PM, Gabor Grothendieck wrote: > On Mon, Oct 4, 2010 at 1:54 PM, Dylan Miracle wrote: >> Hello, >> >> I have a two column dataframe that >> has entries that look like this: >> >> 2315100       NR_024005,NR_024004,AK093685 >> 2315106       DQ786314 >> >> and I want to ch

Re: [R] vectorizing problem

2010-10-04 Thread Gabor Grothendieck
On Mon, Oct 4, 2010 at 1:54 PM, Dylan Miracle wrote: > Hello, > > I have a two column dataframe that > has entries that look like this: > > 2315100       NR_024005,NR_024004,AK093685 > 2315106       DQ786314 > > and I want to change this to look like this: > > 2315100       NR_024005 > 2315100    

Re: [R] vectorizing problem

2010-10-04 Thread David Winsemius
On Oct 4, 2010, at 2:02 PM, Henrique Dallazuanna wrote: Try this: do.call(rbind.data.frame, mapply(cbind, DF$V1, strsplit(as.character(DF$V2), ","))) Also try: > txt V1 V2 1 2315100 NR_024005,NR_024004,AK093685 2 2315106 DQ786314 > st

Re: [R] vectorizing problem

2010-10-04 Thread Dimitris Rizopoulos
try this: GPL <- data.frame(x = c(2315100, 2315106), y = c("NR_024005,NR_024004,AK093685", "DQ786314")) sp <- strsplit(as.character(GPL$y), ",") ni <- sapply(sp, length) data.frame(x = rep(GPL$x, ni), y = unlist(sp)) I hope it helps. Best, Dimitris On 10/4/2010 7:54 PM, Dylan Miracle wr

Re: [R] vectorizing problem

2010-10-04 Thread Henrique Dallazuanna
Try this: do.call(rbind.data.frame, mapply(cbind, DF$V1, strsplit(as.character(DF$V2), ","))) On Mon, Oct 4, 2010 at 2:54 PM, Dylan Miracle wrote: > Hello, > > I have a two column dataframe that > has entries that look like this: > > 2315100 NR_024005,NR_024004,AK093685 > 2315106 DQ7