how can I delete neasted for loop

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

how can I delete neasted for loop

This post has NOT been accepted by the mailing list yet.
Hi everybody, I have this little code composed of two neasted for loop:

for (i in 1:nrow(DF1)) {
  ifelse(DF1[i, 1] != DF1[i-1, 1], z<-1,'')
  indexColonnaDF2 <- which(DF1[i, 1] == colnames(DF2))
  indexRigaDf3 <- which(as.character(DF1[i, 2]) == as.character(DF3$sample))
  for (j in 1:nrow(DF2)) {
    indexDf3 <- which(as.character(DF2[j, indexColonnaDF2]) == colnames(DF3))
    DFfinale1[z,indexColonnaDF2] <- DF3[indexRigaDf3,indexDf3]
    z = z + 1

I am a newbie and i would like to know how can I get the same result using the R function and deleting for loop?

Sorry for my bad english

thank you so much

have a good evening