How to use the sort () and order () functions of R language
In this article Xiaobian for you to introduce in detail "R language sort () and order () function how to use", detailed content, clear steps, details handled properly, I hope that this "R language sort () and order () function how to use" article can help you solve doubts, following the editor's ideas slowly in-depth, together to learn new knowledge.
Sort vector elements based on sort () or order: returns the sorted vector, which returns the original sorted index, for example, based on the vector An operation (A can also be numeric): > Abelic ("A", "B", "D", "C", "H", "J", "E") 1, sort sort (x, decrea...)
Sort vector elements based on sort () or order: returns the sorted vector, which returns the original sorted index
For example, based on the vector An operation (A can also be numeric):
> Aventic ("A", "B", "D", "C", "H", "J", "E")
1 、 sort
Sort (x, decreasing = FALSE,...)
Default ascending order
> newA1=sort (A) > newA1 [1] "A"B"C"D"E"H"J"
Descending order: setting decreasing=T
> newA2=sort (A _ decreasing = T) > newA2 [1] "J", "H", "E", "D", "C", "B"A"
2 、 order
Order (..., na.last = TRUE, decreasing = FALSE, method = c ("auto", "shell", "radix"))
Default ascending order, return index, get sort value based on index
> order1=order (A) > order1 [1] 1 2 4 3 7 56 6 > A [order1] [1] "A", "B", "C", "D", "E", "H"J"
Descending order: setting decreasing=T
> order2=order (A decreasing = T) > order2 [1] 6 57 3 4 21 > A [order2] [1] "J", "H", "E", "D", "C", "B" and "A". The article "how to use sort () and order () in R language" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.