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

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

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

                                        Cross Tabulation and Table Creation
                                         交叉制表和创建表

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

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

table uses the cross-classifying factors to build a contingency table of the counts at each combination of factor levels.
table使用交叉分类的因素,建立在每个因子水平组合的应急表计数。


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


table(..., exclude = if (useNA == "no") c(NA, NaN), useNA = c("no",
    "ifany", "always"), dnn = list.names(...), deparse.level = 1)

as.table(x, ...)
is.table(x)

## S3 method for class 'table'
as.data.frame(x, row.names = NULL, ...,
              responseName = "Freq", stringsAsFactors = TRUE)



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

参数:...
one or more objects which can be interpreted as factors (including character strings), or a list (or data frame) whose components can be so interpreted.  (For as.table and as.data.frame, arguments passed to specific methods.)
一个或多个因素(包括字符串),或列表(或数据框)的组件,可以这样解释,可作为解释的对象。 (as.table和as.data.frame,参数传递给具体的方法。)


参数:exclude
levels to remove from all factors in .... If set to NULL, it implies useNA="always".  
从...所有因素的水平。如果设置为NULL,它意味着useNA="always"。


参数:useNA
whether to include extra NA levels in the table.
是否包括额外的NA表中的水平。


参数:dnn
the names to be given to the dimensions in the result (the dimnames names).
名称,尺寸,结果“(dimnames名)。


参数:deparse.level
controls how the default dnn is constructed.  See details.
如何默认dnn构造的控制。查看详情。


参数:x
an arbitrary R object, or an object inheriting from class "table" for the as.data.frame method.
任意一个R对象或对象类继承"table"as.data.frame方法。


参数:row.names
a character vector giving the row names for the data frame.
字符向量数据框的行名。


参数:responseName
The name to be used for the column of table entries, usually counts.
表项的列名,通常计数。


参数:stringsAsFactors
logical: should the classifying factors be returned as factors (the default) or character vectors?
逻辑:应分类因素因素(默认)或字符向量作为返回?


Details

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

If the argument dnn is not supplied, the internal function list.names is called to compute the "dimname names".  If the arguments in ... are named, those names are used.  For the remaining arguments, deparse.level = 0 gives an empty name, deparse.level = 1 uses the supplied argument if it is a symbol, and deparse.level = 2 will deparse the argument.
如果参数dnn没有提供,内部功能list.names被称为计算“dimname名称”。如果...的参数命名,使用这些名字。对于剩下的参数,deparse.level = 0给出了一个空的名字,deparse.level = 1使用提供的参数,如果它是一个符号,和deparse.level = 2将deparse的说法。

Only when exclude is specified and non-NULL (i.e., not by default), will table potentially drop levels of factor arguments.
只有当exclude指定和非NULL(即,默认),将table可能下降的因素参数水平。

Both exclude and useNA operate on an "all or none" basis.  If you want to control the dimensions of a multiway table separately, modify each argument using factor or addNA.
既exclude和useNA“全或无”的基础上运作。如果你想控制分开多路表的尺寸,修改每个参数使用factor或addNA。

The summary method for class "table" (used for objects created by table or xtabs) which gives basic information and performs a chi-squared test for independence of factors (note that the function chisq.test currently only handles 2-d tables).
summary类的方法"table"(用于table或xtabs创建的对象)提供了基本的信息,并执行独立的因素(注卡方检验,函数chisq.test目前只能处理2-D表)。


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

table() returns a contingency table, an object of class "table", an array of integer values. Note that unlike S the result is always an array, a 1D array if one factor is given.
table()返回一个应急表,对象类"table",一个整数值阵列。请注意,不像S的结果始终是一个数组,一维数组,如果给出一个因素。

as.table and is.table coerce to and test for contingency table, respectively.
as.table和is.table要挟和应变表,分别测试。

The as.data.frame method for objects inheriting from class "table" can be used to convert the array-based representation of a contingency table to a data frame containing the classifying factors and the corresponding entries (the latter as component named by responseName).  This is the inverse of xtabs.
as.data.frame类"table"继承对象的方法可以用来转换基于阵列的应变表表示数据框包含的分类因素和相应的条目(后者作为组件命名responseName)。这是逆xtabs。


参考文献----------References----------

The New S Language. Wadsworth & Brooks/Cole.

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

tabulate is the underlying function and allows finer control.
tabulate的基本功能,并允许更精细的控制。

Use ftable for printing (and more) of multidimensional tables.  margin.table, prop.table, addmargins.
使用ftable多维表(及以上)用于印刷。 margin.table,prop.table,addmargins。


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


require(stats) # for rpois and xtabs[为rpois和xtabs]
## Simple frequency distribution[#简单的频率分布]
table(rpois(100,5))
## Check the design:[#检查设计:]
with(warpbreaks, table(wool, tension))
table(state.division, state.region)

# simple two-way contingency table[简单的双向应变表]
with(airquality, table(cut(Temp, quantile(Temp)), Month))

a <- letters[1:3]
table(a, sample(a))                    # dnn is c("a", "")[DNN是C(“A”,“”)]
table(a, sample(a), deparse.level = 0) # dnn is c("", "")[DNN是C(“”,“”)]
table(a, sample(a), deparse.level = 2) # dnn is c("a", "sample(a)")[DNN是C(“A”,“样本(一)”)]

## xtabs() &lt;-&gt; as.data.frame.table() :[#xtabs()< - > as.data.frame.table():]
UCBAdmissions ## already a contingency table[#已经是一个应急表]
DF <- as.data.frame(UCBAdmissions)
class(tab &lt;- xtabs(Freq ~ ., DF)) # xtabs &amp; table[xtabs及表]
## tab *is* "the same" as the original table:[作为原始表“相同的”#“选项卡*:]
all(tab == UCBAdmissions)
all.equal(dimnames(tab), dimnames(UCBAdmissions))

a <- rep(c(NA, 1/0:3), 10)
table(a)
table(a, exclude=NULL)
b <- factor(rep(c("A","B","C"), 10))
table(b)
table(b, exclude="B")
d <- factor(rep(c("A","B","C"), 10), levels=c("A","B","C","D","E"))
table(d, exclude="B")
print(table(b,d), zero.print = ".")

## NA counting:[#不适用计数:]
is.na(d) <- 3:4
d. <- addNA(d)
d.[1:7]
table(d.) # ", exclude = NULL" is not needed[“,排除= NULL,”不需要]
## i.e., if you want to count the NA's of 'd', use[#即,如果你想算NA的“D”,使用]
table(d, useNA="ifany")

## Two-way tables with NA counts. The 3rd variant is absurd, but shows[#双向无计数表。第三变种是荒谬的,但显示]
## something that cannot be done using exclude or useNA. [#不能做的东西排除或useNA。]
with(airquality,
   table(OzHi=Ozone > 80, Month, useNA="ifany"))
with(airquality,
   table(OzHi=Ozone > 80, Month, useNA="always"))
with(airquality,
   table(OzHi=Ozone > 80, addNA(Month)))

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-23 00:47 , Processed in 0.030789 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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