Dear all
I'm Ibtesam. I use R program in my studded. I have been seeing problem in rank function. It works as a wrong way from vector to other. I run this code many times, in every time I obtained this result; 1- When I enter this data vector manually, I obtain the correct ranking. It gives the same rank for equal values. Example from the following data: rank(abs(0.2,0.2,-0.2))= 4 4 4 > k=c(-.9,.2,-1.1,.5,-.8,.3,-1,.6,-1.3,-.2,-1.5,.1,-1.2,-.1,-1.4,.2,-.6,.5,-.8,.8) > rank(abs(k)) [1] 14.0 4.0 16.0 7.5 12.0 6.0 15.0 9.5 18.0 4.0 20.0 1.5 17.0 1.5 19.0 [16] 4.0 9.5 7.5 12.0 12.0 2- When I obtain the same data vector from some operations, I obtain a wrong ranking. It gives the different ranks for equal values. Example from the following data: rank(abs(0.2,-0.2,0.2))= 3 4.5 4.5 > x=c(2.9,3,2.5,2.6,3.2) > y=c(3.8,2.7,4,2.4) > z=rep(0,length(x)*length(y)) > sizez=1 > for(i in 1:length(x)) + for(j in 1:length(y)) + {z[sizez]=x[i]-y[j]; sizez=sizez+1;} > z [1] -0.9 0.2 -1.1 0.5 -0.8 0.3 -1.0 0.6 -1.3 -0.2 -1.5 0.1 -1.2 -0.1 -1.4 [16] 0.2 -0.6 0.5 -0.8 0.8 > R=rank(abs(z)) > R [1] 14.0 3.0 16.0 7.5 11.5 6.0 15.0 10.0 18.0 4.5 20.0 1.5 17.0 1.5 19.0 [16] 4.5 9.0 7.5 11.5 13.0 I try many times but I have not known what is the mistake. Can you kindly help me to solve this problem? Thank you. Ibtesam. _________________________________________________________________ [[alternative HTML version deleted]] _______________________________________________ R-SIG-GUI mailing list R-SIG-GUI@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-gui