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 NR_024004 2315100 AK093685 2315106 DQ786314 I can do this with the following "for" loop but the dataframe (GPL) has ~140,000 rows and this takes about 15 minutes: extGPL <- matrix(nrow=0,ncol=2) for (i in 1:length(GPL[,2])){ aa <- unlist(strsplit(as.character(GPL[i,2]),"\\,")) bb <- rep(as.numeric(as.character(GPL[i,1])), length(aa)) cc <- matrix(c(bb,aa),ncol = 2) extGPL <- rbind(extGPL,cc) } Is there a way to vectorize this? Thanks, Dylan Miracle University of Minnesota GCD Department ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.