The rank function works on characters and not only numbers. When a vector of characters is evaluated through rank in R, it orders the characters based on alphabeticalorder.The basic form of the rank() function has the form of rate(vector) and it produces a vector that contains the rank of the values in the vector that was evaluated such that the lowest value would have a rank of 1 and the second-lowest value would have a rank of 2. This is the basics of how to rank data in r. If you look closely at this example, you. Rank in R has an optional term called na.last and it can have four values TRUE is the default value used when this option is emitted. It ranks an NA value last giving it the highest rank. FALSE ranks an NA value first giving it a rank of 1. NA does not rank an NA value. “keep” ranks an NA value with a rank of NA.When ranking in R, you have the ties.method for handling duplicates which can have five values. “average” returns the average values for the duplicates. It is also the default value when this option is missing. “first” ranks the first duplicate first. “random” ranks duplicates in random order. “max” and “min” assignduplicate values the maximum or m. Here is an application of how to rank data in R using the data set mtcars. Here, we are using ranking in r to find the numerical order are the miles per gallon the first ten cars in the list. Note that the first two are identical in one has a ranking a five in the other six because of the ties.method being “first.” The same thing occurs with the 3r.