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

R语言:addmargins()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 17:24:37 | 显示全部楼层 |阅读模式
addmargins(stats)
addmargins()所属R语言包:stats

                                         Puts Arbitrary Margins on Multidimensional Tables or Arrays
                                         对多维表或数组的任意边距

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

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

For a given table one can specify which of the classifying factors to expand by one or more levels to hold margins to be calculated.  One may for example form sums and means over the first dimension and medians over the second.  The resulting table will then have two extra levels for the first dimension and one extra level for the second.  The default is to sum over all margins in the table.  Other possibilities may give results that depend on the order in which the margins are computed.  This is flagged in the printed output from the function.
对于一个给定的表,可以指定由一个或多个级别的分类因素的扩大举行利润率来计算。一个可能的例子形式的款项,并在第一维和中位数在第二个手段。结果表,届时将有两个第一维和第二额外级别的额外水平。默认是总结表中的所有利润。其他可能性可能会依赖上的利润率计算的结果。这是标记在打印输出的功能。


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


addmargins(A, margin = seq_along(dim(A)), FUN = sum, quiet = FALSE)



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

参数:A
table or array.  The function uses the presence of the "dim" and "dimnames" attributes of A.
表或数组。该函数使用"dim"和"dimnames"属性A的存在。


参数:margin
vector of dimensions over which to form margins.  Margins are formed in the order in which dimensions are specified in margin.
向量的尺寸来形成利润。利润形成尺寸margin指定的顺序。


参数:FUN
list of the same length as margin, each element of the list being either a function or a list of functions.  Names of the list elements will appear as levels in dimnames of the result. Unnamed list elements will have names constructed:  the name of a function or a constructed name based on the position in the table.
相同长度的名单margin,函数或功能列表列表中的每个元素。列表中的元素的名称将出现作为各级的结果dimnames的。无名的列表元素将名称构造函数或构造的名称,根据表中的位置的名称。


参数:quiet
logical which suppresses the message telling the order in which the margins were computed.
逻辑抑制的消息说,其中利润计算顺序。


Details

详情----------Details----------

If the functions used to form margins are not commutative the result depends on the order in which margins are computed.  Annotation of margins is done via naming the FUN list.
如果用于形式利润率的功能是不可交换的结果取决于在利润率计算顺序。保证金的注解是通过命名FUN名单。


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

A table or array with the same number of dimensions as A, but with extra levels of the dimensions mentioned in margin.  The number of levels added to each dimension is the length of the entries in FUN.  A message with the order of computation of margins is printed.
与尺寸相同数量的A表或阵列,但额外的水平在margin提到的尺寸。添加到每个维度的水平是在FUN条目的长度。一个消息利润率计算的顺序被打印出来。


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



Bendix Carstensen, Steno Diabetes Center & Department of
Biostatistics, University of Copenhagen,
<a href="http://www.biostat.ku.dk/~bxc">http://www.biostat.ku.dk/~bxc</a>, autumn 2003.
Margin naming enhanced by Duncan Murdoch.




参见----------See Also----------

table, ftable, margin.table.
table,ftable,margin.table。


举例----------Examples----------


Aye <- sample(c("Yes", "Si", "Oui"), 177, replace = TRUE)
Bee <- sample(c("Hum", "Buzz"), 177, replace = TRUE)
Sea <- sample(c("White", "Black", "Red", "Dead"), 177, replace = TRUE)
(A <- table(Aye, Bee, Sea))
addmargins(A)

ftable(A)
ftable(addmargins(A))

# Non-commutative functions - note differences between resulting tables:[非交换功能 - 注意生成的表之间的差异:]
ftable(addmargins(A, c(1,3),
       FUN = list(Sum = sum, list(Min = min, Max = max))))
ftable(addmargins(A, c(3,1),
       FUN = list(list(Min = min, Max = max), Sum = sum)))

# Weird function needed to return the N when computing percentages[奇怪的功能需要计算百分比时,返回的N]
sqsm <- function(x) sum(x)^2/100
B <- table(Sea, Bee)
round(sweep(addmargins(B, 1, list(list(All = sum, N = sqsm))), 2,
            apply(B, 2, sum)/100, "/"), 1)
round(sweep(addmargins(B, 2, list(list(All = sum, N = sqsm))), 1,
            apply(B, 1, sum)/100, "/"), 1)

# A total over Bee requires formation of the Bee-margin first:[超过蜜蜂总需要蜜蜂利润第一的形成:]
mB <-  addmargins(B, 2, FUN = list(list(Total = sum)))
round(ftable(sweep(addmargins(mB, 1, list(list(All = sum, N = sqsm))), 2,
                   apply(mB,2,sum)/100, "/")), 1)

## Zero.Printing table+margins:[#Zero.Printing表+利润:]
set.seed(1)
x <- sample( 1:7, 20, replace=TRUE)
y <- sample( 1:7, 20, replace=TRUE)
tx <- addmargins( table(x, y) )
print(tx, zero.print = ".")

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-2-2 19:59 , Processed in 0.019517 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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