Calculate Rank of the Values of a Vector in R Programming - rank() Function Last Updated : 15 Jun, 2020 Comments Improve Suggest changes Like Article Like Report rank() function in R Language is used to return the sample ranks of the values of a vector. Equal values and missing values are handled in multiple ways. Syntax: rank(x, na.last) Parameters: x: numeric, complex, character, and logical vector na.last: Boolean Value to remove NAs Example 1: Python3 1== # R program to print rank of a vector values # Creating a vector x <- c(2, 5, 3, 6, -4, NA, 7, Inf, 5) # Calling rank() function rank(x) Output: [1] 2.0 4.5 3.0 6.0 1.0 9.0 7.0 8.0 4.5 Example 2: Python3 1== # R program to print rank of a vector values # Creating a vector x <- c(2, 5, 3, 6, -4, NA, 7, Inf, 5) # Calling rank() function rank(x) # Calling with NA removed rank(x, na.last = FALSE) Output: [1] 2.0 4.5 3.0 6.0 1.0 9.0 7.0 8.0 4.5 [1] 3.0 5.5 4.0 7.0 2.0 1.0 8.0 9.0 5.5 Comment More infoAdvertise with us Next Article Calculate Rank of the Values of a Vector in R Programming - rank() Function N nidhi_biet Follow Improve Article Tags : R Language R Vector-Function Similar Reads Calculate the Cumulative Maxima of a Vector in R Programming - cummax() Function The cumulative maxima is the max value of elements 1 through l for an element l of the given variables. cummax() function in R Language is used to calculate the cumulative maxima of the values of vector passed as arguments. Syntax: cummax(x)Â Parameters:Â x: numeric object Example 1:Â Python3 # R pr 2 min read Sorting of a Vector in R Programming - sort() Function In R Programming Language we can sort a vector in ascending or descending order using the sort() function. The sort() function returns a sorted version of the input vector. sort() function in is used to sort a vector by its values. It takes the Boolean value as an argument to sort in ascending or de 2 min read Calculate Median of elements of a Vector in R Programming - median() Function median() function in R Language is used to calculate the median of the elements of the numeric vector passed as argument. Syntax: median(x, na.rm) Parameters: x: Numeric Vector na.rm: Boolean value to ignore NA Example 1: Python3 1== # R program to calculate median of a vector # Creating vector x1 1 min read Get the Minimum and Maximum element of a Vector in R Programming - range() Function range() function in R Programming Language is used to get the minimum and maximum values of the vector passed to it as an argument. Syntax: range(x, na.rm, finite) Parameters:Â x: Numeric Vectorna.rm: Boolean value to remove NAfinite: Boolean value to exclude non-finite elementsR - range() Function 1 min read Return the Index of the First Maximum Value of a Numeric Vector in R Programming - which.max() Function which.max() function in R Language is used to return the location of the first maximum value in the Numeric Vector. Syntax: which.max(x) Parameters: x: Numeric Vector Example 1: Python3 1== # R program to find index of # first maximum value # Creating a vector x <- c(2, 3, 4, 5, 1, 2, 3, 1, 2) # 1 min read Like