Research breakthrough possible @S-Logix pro@slogix.in

Office Address

  • 2nd Floor, #7a, High School Road, Secretariat Colony Ambattur, Chennai-600053 (Landmark: SRM School) Tamil Nadu, India
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to implement rank, order and sort function in R?

Description

To implement the rank, order and sort function using R programming.

Process

Rank :

   Returns a vector with the "rank" of each value

   R Function :rank()

Order :

   Returns the indices that would put the initial vector xin order.

   Using order function to sort a data frame

  R Function :order()

Sort :

   To sort a vector into acsending or descending order

   R Function :sort()

Sapmle Code

#Input Vector
vect<-c(92,22,42,34,66,85,46,36,84)
#Rank Function
rank(vect)

#Order Function
order(vect)
vect[order(vect)]

#Order Using mtcars dataset
attach(mtcars)
mtcars[order(mpg),]

#Sort Function
sort(mtcars$qsec)

Screenshots
implement rank, order and sort function in R
Order Function
Returns a vector with the rank of each value