Really thanks very much, with your help i was able to write a prober code to count the aminoacids in all the cleaved and noncleaved and then to display the results in a matrix with 8 column, i used only two loops instead of three. The code is working but i still have warning telling me that: “In if (x$Label[i] == nc) { ... : the condition has length > 1 and only the first element will be used)” So please can you help me with this warning what is the reason of it as i can’t understand exactly what does it mean? Here is the code that i am using, and the data file is attached: x<-read.table("C:/Uni/502/CA2/hiv.dat", header=TRUE) num<-nrow(x) AA<-c('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y') nc<-x$Label[61:308] c<-x$Label[nc] noncleaved<-function(x) { y<-matrix(0,20,8) colnames(y)<-c("N4","N3","N2","N1","C1","C2","C3","C4") for(i in 1:num){ if (x$Label[i]==nc) { for(j in 1:8){ res<-which(AA==substr(x$Peptide[i],j,j)) y[res, j]=y[res, j]+1 } } } return (y/274*100) } cleaved<-function(x) { y<-matrix(0,20,8) colnames(y)<-c("N4","N3","N2","N1","C1","C2","C3","C4") for(i in 1:num){ if (x$Label[i]==c) { for(j in 1:8){ res<-which(AA==substr(x$Peptide[i],j,j)) y[res, j]=y[res, j]+1 } } } return (y/113*100) } http://n4.nabble.com/file/n1288922/hiv.dat hiv.dat -- View this message in context: http://n4.nabble.com/More-than-on-loop-tp1015851p1288922.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.