structable(vcd)
structable()所属R语言包:vcd
Structured Contingency Tables
结构性列联表
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This function produces a "flat" representation of a high-dimensional contingency table constructed by recursive splits (similar to the construction of mosaic displays).
该函数产生一个平表示递归分裂(类似于马赛克显示器的建设)构成的高维列联表。
用法----------Usage----------
## S3 method for class 'formula'[类formula的方法]
structable(formula, data,
direction = NULL, split_vertical = NULL, ..., subset, na.action)
## Default S3 method:[默认方法]
structable(..., direction = NULL, split_vertical = FALSE)
参数----------Arguments----------
参数:formula
a formula object with possibly both left and right hand sides specifying the column and row variables of the flat table.
可能左和右手侧的平坦表指定的列和行的变量的公式对象。
参数:data
a data frame, list or environment containing the variables to be cross-tabulated, or an object inheriting from class table.
一个数据框,列表或环境中的变量进行交叉制表,或对象继承从类table。
参数:subset
an optional vector specifying a subset of observations to be used. Ignored if data is a contingency table.
一个可选的向量指定要使用的观测值的一个子集。如果忽略data是一个列联表。
参数:na.action
a function which indicates what should happen when the data contain NAs. Ignored if data is a contingency table
一个函数,它表示当数据包含NA的,应该发生什么。如果data是一个列联表忽略
参数:...
R objects which can be interpreted as factors (including character strings), or a list (or data frame) whose components can be so interpreted, or a contingency table object of class "table" or "ftable".
可以解释的因素(包括字符串),或一个列表(或数据框),其组件可以这样解释,或联表对象的类"table"或"ftable"R对象。
参数:split_vertical
logical vector indicating, for each dimension, whether it should be split vertically or not (default: FALSE). Values are recycled as needed. If the argument is of length 1, the value is alternated for all dimensions. Ignored if direction is provided.
逻辑向量表示,每个维度,它是否应该被垂直分割的或不(默认:FALSE“)。价值被回收作为需要。如果参数的长度为1,这个值是交替的所有尺寸。如果忽略direction提供。
参数:direction
character vector alternatively specifying the splitting direction ("h" for horizontal and "v" for vertical splits). Values are recycled as needed. If the argument is of length 1, the value is alternated for all dimensions.
,字符向量或者指定的分裂方向("h"水平和"v"垂直分割)。价值被回收作为需要。如果参数的长度为1,这个值是交替的所有尺寸。
Details
详细信息----------Details----------
This function produces textual representations of mosaic displays, and thus "flat" contingency tables. The formula interface is quite similar to the one of ftable, but also accepts the mosaic-like formula interface (empty left-hand side). Note that even if the ftable interface is used, the split_vertical or direction argument is needed to specify the order of the horizontal and vertical splits. If pretabulated data with a Freq column is used, than the left-hand side should be left empty—the Freq column will be handled correctly.
该函数产生的拼接显示的文字表示,因此,平的列联表。公式的接口是非常相似的ftable一个,但也接受mosaic像公式接口(空左侧)。注意,即使ftable接口使用,split_vertical或需要direction参数指定的顺序的水平和垂直拆分。如果pretabulated一个Freq列的数据比左侧时,应保留为空,Freq列被正确处理。
"structable" objects can be subset using the [ and [[ operators, using either level indices or names (see examples). The corresponding replacement functions are available as well. In addition, appropriate aperm, cbind, rbind, length, dim, and is.na methods do exist.
"structable"对象可以子集,使用[和[[运营商,可以使用指数或名称(参见示例)。以及相应的替换功能。此外,适当的aperm,cbind,rbind,length,dim和is.na方法确实存在。
值----------Value----------
An object of class "structable", inheriting from class "ftable", with the splitting information ("split_vertical") as additional attribute.
类的一个对象"structable",继承类"ftable",与分裂的信息("split_vertical")作为额外的属性。
(作者)----------Author(s)----------
David Meyer <a href="mailtoavid.Meyer@R-project.org">David.Meyer@R-project.org</a>
参考文献----------References----------
The strucplot framework: Visualizing multi-way contingency tables with <code>vcd</code>. Journal of Statistical Software, 17(3), 1-48. URL http://www.jstatsoft.org/v17/i03/ and available as <code>vignette("strucplot")</code>.
参见----------See Also----------
strucplot, mosaic, ftable
strucplot,mosaic,ftable
实例----------Examples----------
structable(Titanic)
structable(Titanic, split_vertical = c(TRUE, TRUE, FALSE, FALSE))
structable(Titanic, direction = c("h","h","v","v"))
structable(Sex + Class ~ Survived + Age, data = Titanic)
## subsetting of structable objects[#子集的structable对象]
(hec <- structable(aperm(HairEyeColor)))
## The "[" operator treats structables as a block-matrix and selects parts of the matrix:[#“[”运算符将structables作为一个块矩阵,并选择部分的矩阵:]
hec[1]
hec[2]
hec[1,c(2,4)]
hec["Male",c("Blue","Green")]
## replacement funcion:[#替换funcion:]
tmp <- hec
(tmp[1,2:3] <- tmp[2,c(1,4)])
## In contrast, the "[[" operator treats structables as two-dimensional[#与此相反,“[[”运算符将structables作为两维]
## lists. Indexing conditions on specified levels and thus reduces the dimensionality:[#列出。索引在指定的水平的条件,从而减少了维数:]
## seek subtables conditioning on levels of the first dimension:[#寻求子表的第一个维度水平的调节:]
hec[[1]]
hec[[2]]
## Seek subtable from the first two dimensions, given the level "Male"[#招贤纳士子表从所述第一的两个维度中,给定的电平“男”]
## of the first variable, and "Brown" from the second[编号的第一变量,和“褐色”从第二]
## (the following two commands are equivalent):[#(下面的两个命令是等价的):]
hec[["Male"]][["Brown"]]
hec[[c("Male","Brown")]]
## Seeking subtables by conditioning on row and/or column variables:[#寻求通过调节子表的行和/或列变量:]
hec[["Male","Hazel"]]
hec[[c("Male","Brown"),]]
hec[[c("Male","Brown"),"Hazel"]]
## a few other operations[#其他一些操作]
t(hec)
dim(hec)
dimnames(hec)
as.matrix(hec)
length(hec)
cbind(hec[,1],hec[,3])
as.vector(hec) ## computed on the _multiway_ table[#上_multiway_表计算]
as.vector(unclass(hec))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|