rank(base)
rank()所属R语言包:base
Sample Ranks
样品队伍
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Returns the sample ranks of the values in a vector. Ties (i.e., equal values) and missing values can be handled in several ways.
返回向量中的值的样本行列。可以处理几个方面的关系(即相等的值)和缺失值。
用法----------Usage----------
rank(x, na.last = TRUE,
ties.method = c("average", "first", "random", "max", "min"))
参数----------Arguments----------
参数:x
a numeric, complex, character or logical vector.
一个数字,复杂的,性格或逻辑向量。
参数: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; if "keep" they are kept with rank NA.
控制NA的待遇。 TRUE如果,在数据缺失值放在最后;如果FALSE,他们把第一;如果NA,他们将被删除;如果"keep"他们一直与排名NA。
参数:ties.method
a character string specifying how ties are treated, see "Details"; can be abbreviated.
一个字符串,指定关系如何处理,请参阅“详细资料”可以缩写。
Details
详情----------Details----------
If all components are different (and no NAs), the ranks are well defined, with values in seq_len(x). With some values equal (called "ties"), the argument ties.method determines the result at the corresponding indices. The "first" method results in a permutation with increasing values at each index set of ties. The "random" method puts these in random order whereas the default, "average", replaces them by their mean, and "max" and "min" replaces them by their maximum and minimum respectively, the latter being the typical sports ranking.
如果所有组件是不同的(并没有NAS),以及定义的行列,在seq_len(x)值。一些值相等(称为关系),参数ties.method决定在相应指数的结果。 "first"在增加值的关系设定每个索引的排列方法的结果。 "random"方法使这些随机顺序,而默认情况下,"average",取代他们的平均值,和"max"和"min"取代了他们的最高和最低分别后者是典型的体育排名。
NA values are never considered to be equal: for na.last = TRUE and na.last = FALSE they are given distinct ranks in the order in which they occur in x.
NA值永远不会被认为是相等的:na.last = TRUE和na.last = FALSE给他们在不同的队伍,他们的顺序出现在x。
<STRONG>NB</STRONG>: rank is not itself generic but xtfrm is, and rank(xtfrm(x), ....) will have the desired result if there is a xtfrm method. Otherwise, rank will make use of ==, > and is.na methods for classed objects, possibly rather slowly.
<STRONG>注:</ STRONG>:rank本身并不是通用,但xtfrm,rank(xtfrm(x), ....)将有预期的结果,如果有一个xtfrm方法。否则,rank将使用==,>和is.na类对象的方法,可能相当缓慢。
值----------Value----------
A numeric vector of the same length as x with names copied from x (unless na.last = NA, when missing values are removed). The vector is of integer type unless ties.method = "average" when it is of double type (whether or not there are any ties).
数字向量的长度相同x复制x(除非na.last = NA,失踪时的值将被删除)的名称。向量是整数类型,除非ties.method = "average"当它是double类型(不论是否有任何关系)。
参考文献----------References----------
The New S Language. Wadsworth & Brooks/Cole.
参见----------See Also----------
order and sort.
order和sort。
举例----------Examples----------
(r1 <- rank(x1 <- c(3, 1, 4, 15, 92)))
x2 <- c(3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5)
names(x2) <- letters[1:11]
(r2 <- rank(x2)) # ties are averaged[关系的平均值]
## rank() is "idempotent": rank(rank(x)) == rank(x) :[#()“幂等”:排名(排名(X))==排名(X):]
stopifnot(rank(r1) == r1, rank(r2) == r2)
## ranks without averaging[#不平均排名]
rank(x2, ties.method= "first") # first occurrence wins[第一次出现的获胜]
rank(x2, ties.method= "random") # ties broken at random[在随机打破的关系]
rank(x2, ties.method= "random") # and again[并再次]
## keep ties ties, no average[#保持联系的纽带,没有平均]
(rma <- rank(x2, ties.method= "max")) # as used classically[用经典]
(rmi <- rank(x2, ties.method= "min")) # as in Sports[体育]
stopifnot(rma + rmi == round(r2 + r2))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|