How to sort R DataFrame by the contents of a column ?
In this article, we will discuss how to sort DataFrame by the contents of the column in R Programming language. We can use the order() function for the same. order() function with the provided parameters returns a permutation that rearranges its first argument into ascending or descending order, breaking ties by further arguments.
Syntax: order(x, decreasing = TRUE/FALSE, na.last = TRUE or FALSE, method = c(“auto”, “shell”, “quick”, “radix”))
- x: data-frames, matrices, or vectors
- decreasing: TRUE then sort in descending order / FALSE then sort in ascending order.
- na.last: TRUE then NA indices are put at last / FALSE then NA indices are put first.
- method: sorting method.
Return: returns a permutation that rearranges its first argument into ascending or descending order of the data frame, vector, matrix, etc.
My Personal Notes arrow_drop_up
Please Login to comment...