函数功能:
Sort (or order) a vector or factor (partially) into ascending or descending order.
排序: 以升序或者降序对向量或者因子进行排序
函数语法:
sort(x, decreasing = FALSE, na.last = NA, ...)
函数参数:
X:
an R object
要排序的R对象
decreasing
logical. Should the sort be increasing or decreasing?
降序:逻辑值,升序还是降序排列
na.last
for controlling the treatment of NAs.
If TRUE, missing values in the data are put last;
if FALSE, they are put first;
if NA, they are removed.
缺失值NA处理:
当取值为TRUE时,缺失值被放在最后面;当取值为FALSE时,缺失值被放在最前面;当取值为NA时,缺失值被移除,不做考虑
index.return
logical indicating if the ordering index vector should be returned as well.
when na.last = NA (the default) and fully sorting non-factors.
返回排序索引向量:
逻辑型,显示是否也需要返回索引向量,当na.last取值为NA且对非因子变量排序时才能使用。
官方文档sort()函数