I have a problem as below.
rept4<-"CGCCCCCTGCTGGCGACTAGGGCAACTGCAGGGTCCTCTTGCTCAAGGTGAGTGGCAGACGCCCACCTGCTGGCAGCCGGGGACACTGCAGGGCCCTCTTGCTTACTGTATAGTGGTGGCA"
rept4<-unlist(strsplit(rept4,""))
Now as per suggestion I have a list of dataframes as below.
i1 <- 5:15
lst <- lapply(i1, function(x) data.frame(setNames(replicate(x,character(0)),
paste0("C", seq_len(x))), stringsAsFactors = FALSE))
names(lst) <- paste0("len", i1)
My question is how to put data inside every dataframe from within a loop depending upon the length.
for ( x in 5: 15){
arr4len<-length(rept4)
windowsize<-x
numrows<-ceiling(arr4len/windowsize)
k<-0
for (i in 1:numrows){
for(j in 1:windowsize){
k<-k+1
lst$lenx[i,j]<-rept4[k]
}
}
}
Here I am trying to access lst$lenx
and x-th element like lst$len10
or lst$len11
etc.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…