here you are the whole code, and the data 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] %in% 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] %in% nc) + { + 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) + } > > hi<-function(x) + { + height<-rep(0,8) + for (j in 1:8){ + height[j]<-sum(round(cleaved(x)[,j])) + max.height<-max(height) + } + plot(c(0,10*8),c(0,max.height+20),col="white") + } > recta<-function(x) + { + colmap<-c("#FFFFFF", "#FFFFCC", "#FFFF99", "#FFFF66", "#FFFF33", + "#FFFF00", "#FFCCFF", "#FFCCCC", "#FFCC99", "#FFCC66", "#FFCC33", + "#FFCC00", "#FF99FF", "#FF99CC", "#FF9999", "#FF9966", "#FF9933", + "#FF9900", "#FF33FF", "#FF33CC") + for (j in 1:8){ + xx<-j*10 + for(k in 1:20){ + yy<-round(cleaved(x)[k,j]) + rect(xx,yy,xx+10,yy+round(cleaved(x)[k,j]),col=colmap[k]) + } + } + } -- View this message in context: http://n4.nabble.com/More-than-on-loop-tp1015851p1290019.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.