找回密码
 注册
查看: 450|回复: 0

R语言 rockchalk包 combineLevels()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-27 22:41:07 | 显示全部楼层 |阅读模式
combineLevels(rockchalk)
combineLevels()所属R语言包:rockchalk

                                        recode a factor by "combining" levels
                                         重新编写的一个因素结合“”水平

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

If a factor variable is currently coded with levels c("Male","Female","Man", "M"), and the user needs to combine the redundant levels for males, this is the function to use!
如果一个因素变量目前编码与水平。(“男”,“女”,“人”,“M”),并且用户需要结合为男性的冗余水平,这是要使用的函数!


用法----------Usage----------


  combineLevels(fac, levs, newLabel)



参数----------Arguments----------

参数:fac
An R factor variable, either ordered or not.
R因子变量,无论是有序或没有。


参数:levs
The levels to be combined. Users may specify either a numerical vector of level values, such as c(1,2,3), to combine the first three elements of level(fac), or they may specify level names.  This can be done as a character vector of *correctly spelled* factor values, such as c("Yes","Maybe","Always") or it may be provided as a subset of the output from levels, such as levels(fac)[1:3].
的电平来进行组合。用户可以指定一个数值向量电平值,如c(1,2,3),结合前三个元素的水平(FAC),或者他们可以指定级别名称。这是可以做到等*正确拼写的*因子值,如c(“是”,“可能”,“总是”),或者它可以被提供作为各级的输出的一个子集,一个字符的矢量作为作为水平(FAC)[1:3]。


参数:newLabel
A character string that represents the label of the new level to be created when levs values are combined.
一个字符串,表示该标签levs值结合时创建新的水平。


Details

详细信息----------Details----------

If the factor is an ordinal factor, then levels may be combined only if they are adjacent. That is to say, a factor with levels c("Lo","Med","Hi","Extreme") allows us to combine responses "Lo" and "Med", while it will NOT allow us to combine "Lo" with "Hi".
如果系数是一个序的因素,那么水平可能进行组合,仅当它们是相邻的。也就是说,C级(“劳”,“中”,“喜”,“至尊”),使我们能够结合“螺”和“中”的回应的一个因素,虽然它不会让我们将“老”与“喜”。

A non-ordered factor can be reorganized to combine any values, no matter what positions they occupy in the levels vector.
非秩序的因素进行重组,合并的任何值,无论什么样的立场,他们占据的水平矢量。


值----------Value----------

A new factor variable, with unused levels removed.
一个新的因素的变量,删除未使用的。


(作者)----------Author(s)----------



Paul E. Johnson <pauljohn@ku.edu>




实例----------Examples----------


x <- c("M","A","B","C","A","B","A","M")
x <- factor(x)
levels(x)
x2a <- combineLevels(x, levs = c("M","A"), newLabel = "M_or_A")
addmargins(table(x2a, x, exclude=NULL))
x2b <- combineLevels(x, c(1,4), "M_or_A")
addmargins(table(x2b, x, exclude=NULL))
x3 <- combineLevels(x, levs = c("M","A","C"), newLabel = "MAC")
addmargins(table(x3, x, exclude=NULL))
## Now an ordinal factor[#现在一个有序的因素]
z <- c("M","A","B","C","A","B","A","M")
z <- ordered(z)
levels(z)
table(z, exclude=NULL)
z2a <-  combineLevels(z, levs = c(1,2), "Good")
addmargins(table(z2a, z, exclude = NULL))
z2b <- combineLevels(z, levs = c("A","B"), "AorB")
addmargins(table(z2b, z, exclude = NULL))
## Should fail:[#失败:]
## z2 &lt;- combineLevels(z, levs=c("A","C"), "Whoops!")[#Z2 < -  combineLevels(Z,列弗= C(“A”,“C”),“哎呦!”)]

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-25 11:59 , Processed in 0.025208 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表