Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the sort () and order () functions of R language

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report