I am having a problem with a loop. I have a data frame:
Transcript=c(1,1,1,1,2,2,2,2,2)
Exon=rep(c(1:4,1:5))
S=c("aaa","ttt","ccc","ggg","ata","tat","cgc","gcg","bbb")
E=c("AAA","TTT","CCC","GGG","ATA","TAT","CGC","GCG","BBB")
DF=data.frame(Transcript, Exon, S, E)
DF
s=split( DF , DF$Transcript,)
I want to subset the dataframe by Transcript and paste column E with S together to give all possible combinations in each transcript. For example, for Transcript 1, I want to return:
AAAaaa,AAAttt,AAAccc,AAAggg,TTTaaa,TTTttt,TTTccc,TTTggg,CCCaaa,CCCttt,CCCccc,CCCggg,GGGaaa,GGGttt,GGGccc,GGGggg.
I have tried the following loop, but it only returns the AAAaaa AAAttt AAAccc AAAggg:
for(i in 1:nrow(s[[1]])){p=paste(s[[1]][1,4],s[[1]][1:i,3],sep="")}
How to I create this loop?