hello every one, How to function more than one loop in R? I have the following problem to be solved with the a method of three loops, can you help me please?
The data is attached with this message. The data is composed of two parts, cleaved (denoted by “cleaved”) and non cleaved (denoted by “noncleaved”). • to access to the ith peptide, you can use X$Peptide[i] • to access to the ith label, you can use X$Label[i] define a set of amino acids using string or other format if you want amino.acid<-"ACDEFGHIKLMNPQRSTVWY" define two matrices with initialised entries, one for cleaved peptides and one for none-cleaved peptides • matrix(0,AA,mer),where AA is the number of amino acids, and mer is the number of residues detected from data using the nchar function • both matrices have the same size, the number of rows being equal to the number of amino acids and the number of columns being equal to the number of residues in peptides use one three-loop structure to detect the frequency of amino acids in cleaved peptides and one three-loop structure to detect the frequency of amino acids in non-cleaved peptides. They should not be mixed in one three-loop structure. The best way to handle this is to use a function. The three-loop structure is exampled as below for(i in 1:num)#scanning data for all peptides, where num means the number of peptides { for(j in 1:mer)#scanning all residues in a peptide { for(k in 1:AA)#scanning 20 amino acids { #actions } } } http://n4.nabble.com/file/n1015851/hiv.dat hiv.dat -- View this message in context: http://n4.nabble.com/More-than-on-loop-tp1015851p1015851.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.