mosaicplot(graphics)
mosaicplot()所属R语言包:graphics
Mosaic Plots
马赛克图解
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Plots a mosaic on the current graphics device.
绘制当前图形设备上的马赛克。
用法----------Usage----------
mosaicplot(x, ...)
## Default S3 method:[默认方法]
mosaicplot(x, main = deparse(substitute(x)),
sub = NULL, xlab = NULL, ylab = NULL,
sort = NULL, off = NULL, dir = NULL,
color = NULL, shade = FALSE, margin = NULL,
cex.axis = 0.66, las = par("las"), border = NULL,
type = c("pearson", "deviance", "FT"), ...)
## S3 method for class 'formula'[类formula的方法]
mosaicplot(formula, data = NULL, ...,
main = deparse(substitute(data)), subset,
na.action = stats::na.omit)
参数----------Arguments----------
参数:x
a contingency table in array form, with optional category labels specified in the dimnames(x) attribute. The table is best created by the table() command.
在数组形式的应急表,可选的dimnames(x)属性指定的类标签。该表是最好的table()命令创建。
参数:main
character string for the mosaic title.
镶嵌标题字符串。
参数:sub
character string for the mosaic sub-title (at bottom).
马赛克副标题字符串(底部)。
参数:xlab,ylab
x- and y-axis labels used for the plot; by default, the first and second element of names(dimnames(X)) (i.e., the name of the first and second variable in X).
x和y轴的标签用于图;默认情况下,第一和第二个元素names(dimnames(X))(即X第一和第二个变量的名称)。
参数:sort
vector ordering of the variables, containing a permutation of the integers 1:length(dim(x)) (the default).
向量排序的变量,包含一个整数的排列1:length(dim(x))(默认)。
参数:off
vector of offsets to determine percentage spacing at each level of the mosaic (appropriate values are between 0 and 20, and the default is 20 times the number of splits for 2-dimensional tables, and 10 otherwise. Rescaled to maximally 50, and recycled if necessary.
偏移向量,以确定在每个马赛克的水平(适当的值是0到20之间,默认是20倍分割为2维表,否则和10。重新调整,以最大限度地50,如果回收的百分比间距必要的。
参数:dir
vector of split directions ("v" for vertical and "h" for horizontal) for each level of the mosaic, one direction for each dimension of the contingency table. The default consists of alternating directions, beginning with a vertical split.
分裂方向的矢量("v"水平和垂直"h")为每个级别的马赛克,应急表中的每个维度的方向之一。默认由交替的方向,垂直分割开始。
参数:color
logical or (recycling) vector of colors for color shading, used only when shade is FALSE, or NULL (default). By default, grey boxes are drawn. color=TRUE uses a gamma-corrected grey palette. color=FALSE gives empty boxes with no shading.
逻辑或(回收)的矢量彩色底纹的颜色,只用时shade是FALSE或NULL(默认)。默认情况下,灰色框绘制。 color=TRUE使用伽玛校正的灰色调色板。 color=FALSE给没有遮阳的空箱。
参数:shade
a logical indicating whether to produce extended mosaic plots, or a numeric vector of at most 5 distinct positive numbers giving the absolute values of the cut points for the residuals. By default, shade is FALSE, and simple mosaics are created. Using shade = TRUE cuts absolute values at 2 and 4.
逻辑指示是否产生扩展镶嵌图,或最多5给切点残差绝对值的不同正数的数字矢量。默认情况下,shade是FALSE,和简单的马赛克创建。使用shade = TRUE削减绝对值在2和4。
参数:margin
a list of vectors with the marginal totals to be fit in the log-linear model. By default, an independence model is fitted. See loglin for further information.
适合在数线性模型的边际总计向量名单。默认情况下,安装一个独立模型。看到loglin为进一步的信息。
参数:cex.axis
The magnification to be used for axis annotation, as a multiple of par("cex").
放大倍率可用于轴标注,作为par("cex")的倍数。
参数:las
numeric; the style of axis labels, see par.
数值轴标签的风格,看到par。
参数:border
colour of borders of cells: see polygon.
单元格的边框颜色:看到polygon。
参数:type
a character string indicating the type of residual to be represented. Must be one of "pearson" (giving components of Pearson's chi-squared), "deviance" (giving components of the likelihood ratio chi-squared), or "FT" for the Freeman-Tukey residuals. The value of this argument can be abbreviated.
字符串表明残留代表。必须"pearson"(皮尔逊给组件的chi-squared)"deviance"(给组件的可能性比chi-squared),或"FT"弗里曼-之一杜克残差。这一论点的价值都可以缩写。
参数:formula
a formula, such as y ~ x.
如y ~ x公式。
参数:data
a data frame (or list), or a contingency table from which the variables in formula should be taken.
一个数据框(或列表),或formula变量应采取的应变表。
参数:...
further arguments to be passed to or from methods.
进一步的参数被传递到或从方法。
参数:subset
an optional vector specifying a subset of observations in the data frame to be used for plotting.
一个可选的向量数据框中指定观测的一个子集,可用于绘制。
参数:na.action
a function which indicates what should happen when the data contains variables to be cross-tabulated, and these variables contain NAs. The default is to omit cases which have an NA in any variable. Since the tabulation will omit all cases containing missing values, this will only be useful if the na.action function replaces missing values.
这表明应该发生什么时,数据中包含变量是跨表,这些变量包含NA的功能。默认是有NA任何变量的情况下省略。由于制表将忽略所有含缺失值的情况下,这只会是有用的,如果na.action函数取代遗漏值。
Details
详情----------Details----------
This is a generic function. It currently has a default method (mosaicplot.default) and a formula interface (mosaicplot.formula).
这是一个通用的功能。它目前有一个默认的方法(mosaicplot.default)和公式接口(mosaicplot.formula)。
Extended mosaic displays visualize standardized residuals of a loglinear model for the table by color and outline of the mosaic's tiles. (Standardized residuals are often referred to a standard normal distribution.) Cells representing negative residuals are drawn in shaded of red and with broken borders; positive ones are drawn in blue with solid borders.
扩展拼接显示器可视化的马赛克的瓷砖颜色和轮廓表对数线性模型的标准化残差。 (标准化残差通常称为标准正态分布。)代表负残差的单元,是画在红色阴影和破碎的边界;正面的蓝色固体边界绘制。
For the formula method, if data is an object inheriting from class "table" or class "ftable" or an array with more than 2 dimensions, it is taken as a contingency table, and hence all entries should be non-negative. In this case the left-hand side of formula should be empty and the variables on the right-hand side should be taken from the names of the dimnames attribute of the contingency table. A marginal table of these variables is computed, and a mosaic plot of that table is produced.
公式法,data如果继承类"table"类"ftable"或超过2维数组是一个对象,它作为一项应急表,因此所有条目应非负。在这种情况下formula左侧应该是空的,在右边的变量应采取的应急表dimnames属性的名称。这些变量的边际表计算,并制作了该表的镶嵌图。
Otherwise, data should be a data frame or matrix, list or environment containing the variables to be cross-tabulated. In this case, after possibly selecting a subset of the data as specified by the subset argument, a contingency table is computed from the variables given in formula, and a mosaic is produced from this.
否则,data应该是一个数据框或矩阵,列表或环境中包含的变量是跨表。在这种情况下,可能选择的subset参数指定的数据的一个子集后,应急表计算从formula给定的变量,从这个生产马赛克。
See Emerson (1998) for more information and a case study with television viewer data from Nielsen Media Research.
艾默生(1998年)获得更多的信息和案例研究与尼尔森媒介研究的电视观众数据。
Missing values are not supported except via an na.action function when data contains variables to be cross-tabulated.
遗漏值不支持通过na.action时data包含变量是跨表的函数除外。
A more flexible and extensible implementation of mosaic plots written in the grid graphics system is provided in the function mosaic in the contributed package vcd (Meyer, Zeileis and Hornik, 2005).
功能mosaic在实缴包vcd(迈耶,Zeileis和Hornik,2005年)提供一个更加灵活和可扩展的网格中的图形系统书面镶嵌图的实施。
作者(S)----------Author(s)----------
S-PLUS original by John Emerson <a href="mailto:john.emerson@yale.edu">john.emerson@yale.edu</a>.
Originally modified and enhanced for <font face="Courier New,Courier" color="#666666"><b>R</b></font> by Kurt Hornik.
参考文献----------References----------
A mosaic of television ratings. The American Statistician, 38, 32–35.
Mosaic displays in S-PLUS: A general implementation and a case study. Statistical Computing and Graphics Newsletter (ASA), 9, 1, 17–23.
Mosaic displays for multi-way contingency tables. Journal of the American Statistical Association, 89, 190–200.
The strucplot framework: Visualizing multi-way contingency tables with vcd. Report 22, Department of Statistics and Mathematics, Wirtschaftsuniversit鋞 Wien, Research Report Series. http://epub.wu.ac.at/dyn/openURL?id=oai:epub.wu-wien.ac.at:epub-wu-01_8a1
(http://www.math.yorku.ca/SCS/friendly.html) provides information on various aspects of graphical methods for analyzing categorical data, including mosaic plots.
参见----------See Also----------
assocplot, loglin.
assocplot,loglin。
举例----------Examples----------
require(stats)
mosaicplot(Titanic, main = "Survival on the Titanic", color = TRUE)
## Formula interface for tabulated data:[#公式表数据接口:]
mosaicplot(~ Sex + Age + Survived, data = Titanic, color = TRUE)
mosaicplot(HairEyeColor, shade = TRUE)
## Independence model of hair and eye color and sex. Indicates that[#头发和眼睛颜色和性别独立模型。表明]
## there are more blue eyed blonde females than expected in the case [#有更蓝眼金发的女性,比预期的情况下]
## of independence and too few brown eyed blonde females.[#独立和太少,棕色眼睛的金发女性。]
## The corresponding model is:[#相应的模型是:]
fm <- loglin(HairEyeColor, list(1, 2, 3))
pchisq(fm$pearson, fm$df, lower.tail = FALSE)
mosaicplot(HairEyeColor, shade = TRUE, margin = list(1:2, 3))
## Model of joint independence of sex from hair and eye color. Males[#模型的联合性的头发和眼睛颜色的独立性。男性]
## are underrepresented among people with brown hair and eyes, and are[#人数不足之间的棕色头发和眼睛的人,是]
## overrepresented among people with brown hair and blue eyes.[#之间的棕色头发,蓝眼睛的人所占比例过高。]
## The corresponding model is:[#相应的模型是:]
fm <- loglin(HairEyeColor, list(1:2, 3))
pchisq(fm$pearson, fm$df, lower.tail = FALSE)
## Formula interface for raw data: visualize cross-tabulation of numbers[#公式为原料的数据接口:数字可视化交叉制表]
## of gears and carburettors in Motor Trend car data.[#齿轮汽车族汽车数据化油器。]
mosaicplot(~ gear + carb, data = mtcars, color = TRUE, las = 1)
# color recycling[色回收]
mosaicplot(~ gear + carb, data = mtcars, color = 2:3, las = 1)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|