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

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

[复制链接]
发表于 2012-2-22 20:58:18 | 显示全部楼层 |阅读模式
annotateMosaic(SVGAnnotation)
annotateMosaic()所属R语言包:SVGAnnotation

                                        Add tooltips to a Mosaic plot
                                         工具提示添加到镶嵌图

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

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

The function annotateMosaic adds basic tooltips to a mosaic plot for visualizing frequency tables and conditional probabilities. The tooltips help viewers to comprehend what can be a complex plot. The tooltips currently give the count along with the different levels of the categorical variables. One can specify a function that is called to create the tooltip for each cell.
功能annotateMosaic增加了一个可视化的频率表和条件概率的马赛克图的基本工具提示。工具提示,帮助观众理解什么是一个复杂的图。目前的工具提示给计数与分类变量的不同水平。一个可以指定一个名为创建工具提示为每个单元的功能。

Two lower level  functions are getCategoryLabelNodes.mosaic getAxesLabelNodes.mosaic. These return the SVG nodes corresponding to the labels for each category on the different sides of the plot and the SVG nodes for the axes/variable labels, respectively.
两个低级别的功能getCategoryLabelNodes.mosaicgetAxesLabelNodes.mosaic。这些返回相应的SVG节点上的图,不同的侧面和轴/变量标签的SVG节点,分别为每个类别标签。

These functions annotate the SVG nodes with meta-informatio about the type.   This allows us to retrieve the same nodes in subsequent calls even if we have modified the structure of the SVG document as we add markup such as tooltips and links.
这些功能注解元informatio有关类型的SVG节点。这使我们能够在随后的调用检索相同的节点,即使我们已经修改了SVG文档的结构,因为我们添加标记作为提示和链接等。

Note that for the current implementation, if any "row" in the mosaic plot has all cells with zero observations, the subsequent tooltips will be mis-aligned, i.e. some of the latter tooltips will be for the wrong (earlier) cells.
请注意,为目前的执引号况,如果任何镶嵌图中的“行”零意见的所有单元,随后工具提示是错误对齐,即后者的一些工具提示将是错误的单元(早)。


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


annotateMosaic(doc, table, cellTips = NULL,
               axisLabelTips = c(names(attr(table, "col.vars")),
                                 names(attr(table, "row.vars"))),
               categoryTips = getMosaicLabels(table),
               shade = FALSE, addCSS = TRUE)
getCategoryLabelNodes.mosaic(doc, table = NULL,
                              numCells = prod(dim(table)), groupZeros = NA)
getAxesLabelNodes.mosaic(doc, table = NULL, groupZeros = NA)



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

参数:doc
the SVG document, typically created via a call to svgPlot but this can also be the name of a file containing the SVG content or the already parsed document.
SVG文档,通常调用svgPlot通过创建但是这也可以是包含SVG内容的文件或文件已经解析的名称。


参数:table
the frequency table returned by the call to mosaic. This contains the information about the counts and the labels for the variables and their categories/levels and the order in which they were plotted.
由mosaic调用返回的频率表。这包含变量和它们的类别/水平,以便在他们绘制了有关计数和标签的信息。


参数:axisLabelTips
the text for the axes labels tooltips
轴标签的工具提示文本


参数:categoryTips
tooltips for the labels on the axes that identify the different categories of each of the categorical variables.
工具提示为轴线上,确定每个分类变量的不同类别的标签。


参数:shade
a logical value indicating whether the shade parameter was specified as TRUE in the call to mosaic which would then give rise to a legend. It is important to know this to interpret the nodes in the SVG content.
一个逻辑值,指明是否shade参数被指定为TRUE在调用mosaic,然后上升到一个传说。重要的是知道这个解释在SVG内容的节点。


参数:addCSS
a logical value indicating whether to add the (default) CSS to the SVG document or the name of a CSS file or CSS content to add.  
一个逻辑值,该值指示是否添加(默认)的CSS,SVG文件或一个CSS文件的名称或CSS内容添加。


参数:cellTips
a character vector of tool tips for the cells in the plot or a function that is called to compute the tooltip string for a given cell. If this is a function it will be called with a single argument which is a data frame with one row giving the levels of the different categorical variables along with a variable named .count which gives the number of observations in that cell.
一个工具提示中的图或一个被称为工具提示字串计算一个给定的单元的功能单元的特征向量。如果这是一个函数将一个参数是变量名为给予不同的分类变量的水平与一列的数据框称为.count这使该单元格中的若干意见。


参数:numCells
the number of cells in the mosaic plot. This can be specified instead of the table.
镶嵌图的单元数量。这可以被指定,而不是table。


参数:groupZeros
a logical value (or NA) indicating whether to perform the operation that groups SVG elements representing a cell with a zero count together into a single node. This makes processing the SVG easier.
一个逻辑值(或NA)指示是否执行该操作,团体代表计数为零的单元格一起到一个单一的节点SVG元素。这使得处理SVG的更容易。


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

The updated SVG document.
更新后的SVG文档。


注意----------Note----------

At present, we can only handle mosaic plots with less than 5 variables.
目前,我们只能处理少于5个变量的马赛克图。


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



Duncan Temple Lang




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



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

svgPlot
svgPlot


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


if(require(vcd)) {
  a = matrix(as.integer(rnorm(12, 100, 10)), 3, 4, dimnames = list(c("A", "B", "C"), c("W", "X", "Y", "Z")))
  names(dimnames(a)) = c("Var 1", "Var 2")
  saveXML(annotateMosaic(svgPlot(o <- mosaic(a)), o), "simpleMosaic.svg")



  saveXML(annotateMosaic(svgPlot( m <- mosaic(UCBAdmissions)), m), "ucb.svg")




  saveXML(annotateMosaic(svgPlot(z <- mosaic(Survived ~ ., data = Titanic)), z), "titanic.svg")




    # Example of 4 variables with more than 2 categories.[超过2类4个变量的例子。]
  xx = data.frame(a = sample(1:3, 100, TRUE), b = sample(c("A", "B", "C", "D"), 100, TRUE),
                  c = sample(c("X", "Y"), 100, TRUE), d = sample(c("Yes", "No"), 100, TRUE))

  saveXML(annotateMosaic(svgPlot(m <- mosaic(with(xx, table(a, b, c, d)))), m), "multiMosaic.svg")



    # Provide a function for creating the cell tooltip strings.[提供一个创建单元格工具提示字符串的功能。]
  saveXML(annotateMosaic(svgPlot(o <- mosaic(a)), o, cellTips = function(x) x$.count), "mySimpleMosaic.svg")



    # annotate the plot more manually, i.e. specifying links and[更多手动注释图,即指定链接]
    # tooltips for the axes labels and category labels.[工具提示的轴标签和类别标签。]

  data(UCBAdmissions)
  doc = svgPlot( m <- mosaic(UCBAdmissions))

  cats = getCategoryLabelNodes.mosaic(doc, m)
  ax <- getAxesLabelNodes.mosaic(doc, m)

#  annotateMosaic(doc, m, categoryTips = character())[annotateMosaic(DOC,男,categoryTips =字符())]

  mapply(addLink, ax,
           c("http://www.math.yorku.ca/SCS/vcd/",
             "http://cran.r-project.org/web/packages/vcd/index.html",
             "http://www.omegahat.org/SVGAnnotation"))

  tips = c(Rejected = "The applicant was not admitted this year",
           Admitted = "The applicant was admitted ",
    F = "Department of ...",
    E = "Department of ...",
    D = "Department of ...",
    C = "Department of ...",
    B = "Department of ...",
    A = "Department of ...",
    Male = "Applicant was a man",
    Female = "Applicant was a woman")

  addToolTips(cats, tips[names(cats)])
  saveXML(doc, "iucb.svg")
} else {
  warning("You need the vcd package (Visualizing Categorical Data) for these mosaic examples")
}

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-22 15:47 , Processed in 0.034701 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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