

&lt;!--startrecall--&gt;&lt;img src=&quot;http://mail.skku.edu/mail/write/mail_recall.php?f_headindex=1215810-2003022633787-R-help@stat.math.ethz.ch&quot;&gt;&lt;!--endrecall--&gt;

Hello! I have a question on rank function that i&#039;m working on now. 
Even though my English i not good, I hope you understand what i&#039;m asking for. It is a program that i made
(It must not to use the function from the R)
##########################
data&lt;-sample(c(1:100),10)
rank.data &lt;- rep(0,length(data)) 
for(i in 1:length(data)){ 
  for(j in 1:length(data)){ 
    if(data[i]&lt;data[j]){ 
    rank.data[j] &lt;- rank.data[j] + 1 
    }
  }
} 
rank.data &lt;- rank.data + 1 
data 
rank.data 
rank(data) 
##########################

I wrote out again because i wanted to decrease it to 55times for efficiency of calculation.
#########################
data&lt;-sample(c(1:100),10)
test.data&lt;-data
n&lt;-length(data)
min.data&lt;-1000
for(j in 1:10){
for(i in 1:n){
 if(data[i]&lt;min.data){
 min.data &lt;- data[i]
 }}
rank.data[rank.data==min.data]&lt;-j
data &lt;- data[data!=min.data]
}
test.data 
rank.data 
rank(test.data) 
#########################
### This is output ######
Error in if (data[i] &lt; min.data) { : missing value where TRUE/FALSE needed
&gt; test.data 
 [1] 97 25 90 76 85 32 79  8 39 35
&gt; rank.data 
 [1]  3  9  7  4  6 95  1  1  1  5
&gt; rank(test.data) 
 [1] 10  2  9  6  8  3  7  1  5  4
&gt; 
I added it to R after i copied the sources then error occured instead of the result that i wanted. 
How can i get the correct results?  And how can i correct second source?
	[[alternative HTML version deleted]]


