reorder.factor(stats)
reorder.factor()所属R语言包:stats
Reorder Levels of a Factor
重新排列的一个因素水平
译者:生物统计家园网 机器人LoveR
描述----------Description----------
reorder is a generic function. The "default" method treats its first argument as a categorical variable, and reorders its levels based on the values of a second variable, usually numeric.
reorder是一个通用的功能。 "default"方法视为一个明确的变量,它的第一个参数,并重新排序,其水平的基础上的第二个变量,通常数字值。
用法----------Usage----------
reorder(x, ...)
## Default S3 method:[默认方法]
reorder(x, X, FUN = mean, ...,
order = is.ordered(x))
参数----------Arguments----------
参数:x
An atomic vector, usually a factor (possibly ordered). The vector is treated as a categorical variable whose levels will be reordered. If x is not a factor, its unique values will be used as the implicit levels.
一个原子的向量,通常是一个因子(可能顺序排列)。矢量被视为一个明确的变量,其水平将被重新安排。 x如果是不是一个因素,其独特的价值将被用来作为隐含的水平。
参数:X
a vector of the same length as x, whose subset of values for each unique level of x determines the eventual order of that level.
的和x相同长度,为每一个独特的水平值的子集向量x决定该级别的最终秩序。
参数:FUN
a function whose first argument is a vector and returns a scalar, to be applied to each subset of X determined by the levels of x.
函数的第一个参数是一个向量,返回一个标量,被应用到每个子集X由取决于x水平。
参数:...
optional: extra arguments supplied to FUN
可选:额外参数提供FUN的
参数:order
logical, whether return value will be an ordered factor rather than a factor.
逻辑,是否返回值将是一个有序的因素,而不是一个因素。
值----------Value----------
A factor or an ordered factor (depending on the value of order), with the order of the levels determined by FUN applied to X grouped by x. The levels are ordered such that the values returned by FUN are in increasing order. Empty levels will be dropped.
一个因素或一个有序的因子(取决于价值order)FUNXx分组的决心水平的顺序。水平进行排序等FUN递增顺序返回的值。空的水平将会下降。
Additionally, the values of FUN applied to the subsets of X (in the original order of the levels of x) is returned as the "scores" attribute.
此外,FUN值X(在x水平的原始顺序)的子集作为"scores"属性返回。
作者(S)----------Author(s)----------
Deepayan Sarkar <a href="mailto:deepayan.sarkar@r-project.org">deepayan.sarkar@r-project.org</a>
参见----------See Also----------
reorder.dendrogram, levels, relevel.
reorder.dendrogram,levels,relevel。
举例----------Examples----------
require(graphics)
bymedian <- with(InsectSprays, reorder(spray, count, median))
boxplot(count ~ bymedian, data = InsectSprays,
xlab = "Type of spray", ylab = "Insect count",
main = "InsectSprays data", varwidth = TRUE,
col = "lightgray")
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|