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

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

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

                                        General Tree Structures
                                         一般树结构

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

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

Class "dendrogram" provides general functions for handling tree-like structures.  It is intended as a replacement for similar functions in hierarchical clustering and classification/regression trees, such that all of these can use the same engine for plotting or cutting trees.
类"dendrogram"提供处理树状结构的一般功能。它的目的是作为一个层次聚类和分类/回归树类似的功能,例如,所有这些都可以使用相同的引擎,绘制或砍树更换。


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


as.dendrogram(object, ...)
## S3 method for class 'hclust'
as.dendrogram(object, hang = -1, ...)

## S3 method for class 'dendrogram'
as.hclust(x, ...)

## S3 method for class 'dendrogram'
plot(x, type = c("rectangle", "triangle"),
      center = FALSE,
      edge.root = is.leaf(x) || !is.null(attr(x,"edgetext")),
      nodePar = NULL, edgePar = list(),
      leaflab = c("perpendicular", "textlike", "none"),
      dLeaf = NULL, xlab = "", ylab = "", xaxt = "n", yaxt = "s",
      horiz = FALSE, frame.plot = FALSE, xlim, ylim, ...)

## S3 method for class 'dendrogram'
cut(x, h, ...)

## S3 method for class 'dendrogram'
merge(x, y, ..., height)

## S3 method for class 'dendrogram'
print(x, digits, ...)

## S3 method for class 'dendrogram'
rev(x)

## S3 method for class 'dendrogram'
str(object, max.level = NA, digits.d = 3,
    give.attr = FALSE, wid = getOption("width"),
    nest.lev = 0, indent.str = "", last.str = "`", stem = "--",
    ...)

is.leaf(object)



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

参数:object
any R object that can be made into one of class "dendrogram".
任何R的对象,可分为类"dendrogram"。


参数:x,y
object(s) of class "dendrogram".
对象类(S)"dendrogram"。


参数:hang
numeric scalar indicating how the height of leaves should be computed from the heights of their parents; see plot.hclust.
数字标叶片的高度应如何从他们的父母的高度计算;看到plot.hclust。


参数:type
type of plot.
图类型。


参数:center
logical; if TRUE, nodes are plotted centered with respect to the leaves in the branch.  Otherwise (default), plot them in the middle of all direct child nodes.
逻辑;如果TRUE,节点绘制方面分支的叶子中心。否则(默认值),绘制在他们中间的所有直接子节点。


参数:edge.root
logical; if true, draw an edge to the root node.
逻辑;如果属实,画一个边根节点。


参数:nodePar
a list of plotting parameters to use for the nodes (see points) or NULL by default which does not draw symbols at the nodes.  The list may contain components named pch, cex, col, xpd, and/or bg each of which can have length two for specifying separate attributes for inner nodes and leaves.  Note that the default of pch is 1:2, so you may want to use pch = NA if you specify nodePar.
list绘图参数使用节点(见points)NULL默认情况下不会在节点绘制的符号。该列表可能包含名为pch,cex,col,xpd,和/或bg每个可以有单独的属性指定为长度为二的组件内部节点和叶子。需要注意的是默认的pch1:2,所以你可能要使用pch = NA如果你指定了nodePar。


参数:edgePar
a list of plotting parameters to use for the edge segments and labels (if there's an edgetext).  The list may contain components named col, lty and lwd (for the segments), p.col, p.lwd, and p.lty (for the polygon around the text) and t.col for the text color.  As with nodePar, each can have length two for differentiating leaves and inner nodes.  
list的图使用边缘segments“标签的参数(如果有一个edgetext)。该列表可能包含名为col,lty和lwd(段),p.col,p.lwd,p.lty(组件polygon周围的文字)和t.col文字的颜色。 nodePar,每个人都可以有长度为二的区分叶和内部节点。


参数:leaflab
a string specifying how leaves are labeled.  The default "perpendicular" write text vertically (by default).<br> "textlike" writes text horizontally (in a rectangle), and <br> "none" suppresses leaf labels.
一个字符串,指定叶标记。默认"perpendicular"写的文字垂直(默认)。参考"textlike"写的文字水平(矩形),并参考"none"抑制叶片的标签。


参数:dLeaf
a number specifying the distance in user coordinates between the tip of a leaf and its label.  If NULL as per default, 3/4 of a letter width or height is used.
在用户指定的距离,坐标数字之间的尖叶和它的标签。如果NULL按默认情况下,一个字母的宽度或高度的3/4用于。


参数:horiz
logical indicating if the dendrogram should be drawn horizontally or not.
逻辑表明,如果树状图应绘制水平或不。


参数:frame.plot
logical indicating if a box around the plot should be drawn, see plot.default.
逻辑指示是否应制定一箱周围的图,看到plot.default。


参数:h
height at which the tree is cut.
高度的树被切断。


参数:height
height at which the two dendrogram should be merged.  If not specified (or NULL), the default is ten percent larger than the (larger of the) two component heights.
这两个聚类的高度应合并。如果没有指定(或NULL),默认是10%以上(较大)两个组件高度较大。


参数:xlim, ylim
optional x- and y-limits of the plot, passed to plot.default.  The defaults for these show the full dendrogram.
可选的X和Y-限额的图,传递给plot.default。这些默认显示完整的树状图。


参数:..., xlab, ylab, xaxt, yaxt
graphical parameters, or arguments for other methods.
图形参数,或其他方法的参数。


参数:digits
integer specifying the precision for printing, see print.default.
整数,指定的印刷精度,看到print.default。


参数:max.level, digits.d, give.attr, wid, nest.lev, indent.str
arguments to str, see str.default().  Note that give.attr = FALSE still shows height and members attributes for each node.
str参数,看到str.default()。注意give.attr = FALSE仍然显示height和members每个节点的属性。


参数:last.str, stem
strings used for str() specifying how the last branch (at each level) should start and the stem to use for each dendrogram branch.
字符串str()最后一个分支(每级)应指定如何启动和使用每个树状分支干的。


Details

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

The dendrogram is directly represented as a nested list where each component corresponds to a branch of the tree.  Hence, the first branch of tree z is z[[1]], the second branch of the corresponding subtree is z[[1]][[2]], or shorter z[[c(1,2)]], etc..  Each node of the tree carries some information needed for efficient plotting or cutting as attributes, of which only members, height and leaf for leaves are compulsory:
树状图是直接代表一个嵌套列表,其中每个组件对应树的一个分支。因此,第一个分支的树zz[[1]],相应的子树的第二个分支是z[[1]][[2]],或较短的z[[c(1,2)]]等。树的每个节点进行高效的绘图或切割为属性所需要的一些信息,其中仅members,height和leaf的叶子是强制性的:




members total number of leaves in the branch
members总数的叶子在分支




height numeric non-negative height at which the node
height数字非负高度的节点




midpoint numeric horizontal distance of the node from the left border (the leftmost leaf) of the branch (unit 1 between
midpoint数字的水平距离从左边边界的分支(最左边的叶)(1单元之间的节点




label character; the label of the node
label字符;节点的标签




x.member for cut()$upper, the number of former members; more generally a substitute for the members component used for "horizontal"
x.membercut()$upper,前成员的数目;更普遍代替members组件用于“水平”




edgetext character; the label for the edge leading to
edgetext字符导致边缘的标签




nodePar a named list (of length-1 components) specifying node-specific attributes for points
nodePar命名列表(长度为1组件)指定节点的特定属性points




edgePar a named list (of length-1 components) specifying attributes for segments plotting of the edge leading to the node, and drawing of the edgetext if
edgePar命名列表(长度为1组件)指定segments边缘节点绘制,edgetext的绘制属性如果




leaf logical, if TRUE, the node is a leaf of
leaf逻辑,如果TRUE,该节点是一个叶

cut.dendrogram() returns a list with components $upper and $lower, the first is a truncated version of the original tree, also of class dendrogram, the latter a list with the branches obtained from cutting the tree, each a dendrogram.
cut.dendrogram()返回组件列表$upper和$lower,首先是截断了原来的树版本,也是类dendrogram,获得后者的分支机构列表从切割的树,每一个dendrogram。

There are [[, print, and str methods for "dendrogram" objects where the first one (extraction) ensures that selecting sub-branches keeps the class.
有[[print,str"dendrogram"第一个(提取)确保选择支行保持类的对象的方法。

Objects of class "hclust" can be converted to class "dendrogram" using method as.dendrogram(), and since R 2.13.0, there is also a as.hclust() method as an inverse.
"hclust"类的对象可以被转换成类"dendrogram"使用方法as.dendrogram(),自R 2.13.0,也有一个as.hclust()作为一个逆的方法。

rev.dendrogram simply returns the dendrogram x with reversed nodes, see also reorder.dendrogram.
rev.dendrogram只是简单地返回树状x与扭转节点,也见reorder.dendrogram。

The merge(x,y, ...) method allows to join two (or more!) dendrograms into a new one which has x and y (and optional further arguments) as branches.
merge(x,y, ...)方法可以加入到一个新的具有分支x和y(和可选的进一步参数)两个(或更多!)聚类。

is.leaf(object) is logical indicating if object is a leaf (the most simple dendrogram). plotNode() and plotNodeLimit() are helper functions.
is.leaf(object) object如果是叶(最简单的树状)是逻辑。 plotNode()和plotNodeLimit()辅助函数。


警告----------Warning----------

Some operations on dendrograms (including plotting) make use of recursion.  For very deep trees It may be necessary to increase options("expressions"): if you do you are likely to need to set the C stack size larger than the OS default if possible (which it is not on Windows).
聚类(包括策划)一些操作使用递归。对于非常深的树,它可能有必要增加options("expressions"):如果你这样做,你很可能需要比OS的默认设置C堆栈大小,如果可能的话(它不是在Windows上)。


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




plot(): When using type = "triangle",
plot():当使用type = "triangle"




str(d): If you really want to see the internal
str(d):如果你真的想看到内部


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

dendrapply for applying a function to each node. order.dendrogram and reorder.dendrogram; further, the labels method.
dendrapply申请到每个节点的功能。 order.dendrogram和reorder.dendrogram;进一步,labels方法。


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


require(graphics); require(utils)

hc <- hclust(dist(USArrests), "ave")
(dend1 &lt;- as.dendrogram(hc)) # "print()" method[“打印()”方法]
str(dend1)          # "str()" method[“(STR)”的方法]
str(dend1, max = 2, last.str= "'") # only the first two sub-levels[只有前两个子层]

op <- par(mfrow= c(2,2), mar = c(5,2,1,4))
plot(dend1)
## "triangle" type and show inner nodes:[#“三角”的类型和显示内部节点:]
plot(dend1, nodePar=list(pch = c(1,NA), cex=0.8, lab.cex = 0.8),
      type = "t", center=TRUE)
plot(dend1, edgePar=list(col = 1:2, lty = 2:3),
     dLeaf=1, edge.root = TRUE)
plot(dend1, nodePar=list(pch = 2:1,cex=.4*2:1, col = 2:3),
     horiz=TRUE)

## simple test for as.hclust() as the inverse of as.dendrogram():[#简单的测试as.hclust()逆as.dendrogram():]
stopifnot(identical(as.hclust(dend1)[1:4], hc[1:4]))

dend2 <- cut(dend1, h=70)
plot(dend2$upper)
## leaves are wrong horizontally:[#叶子是错误的水平:]
plot(dend2$upper, nodePar=list(pch = c(1,7), col = 2:1))
##  dend2$lower is *NOT* a dendrogram, but a list of .. :[#dend2美元低是*不*树状图,但一个列表...... :]
plot(dend2$lower[[3]], nodePar=list(col=4), horiz = TRUE, type = "tr")
## "inner" and "leaf" edges in different type &amp; color :[#“内部”和“叶”的边缘,在不同类型和颜色:]
plot(dend2$lower[[2]], nodePar=list(col=1),# non empty list[非空列表]
     edgePar = list(lty=1:2, col=2:1), edge.root=TRUE)
par(op)
d3 <- dend2$lower[[2]][[2]][[1]]
stopifnot(identical(d3, dend2$lower[[2]][[c(2,1)]]))
str(d3, last.str="'")

## merge() to join dendrograms:[#合并()加入聚类:]
(d13 <- merge(dend2$lower[[1]], dend2$lower[[3]]))
## merge() all parts back (using default 'height' instead of original one):[#合并()的所有部分(使用默认的“高度”,而不是原来的):]
den.1 <- Reduce(merge, dend2$lower)
## or merge() all four parts at same height --&gt; 4 branches (!)[#或合并()在同一高度的所有四个部分 - > 4家分行(!)]
d. <- merge(dend2$lower[[1]], dend2$lower[[2]], dend2$lower[[3]],
            dend2$lower[[4]])
## (with a warning) or the same using  do.call :[#(警告),或同时使用do.call:]
stopifnot(identical(d., do.call(merge, dend2$lower)))
plot(d., main="merge(d1, d2, d3, d4)  |->  dendrogram with a 4-split")

## "Zoom" in to the first dendrogram :[#“放大”第一树状]
plot(dend1, xlim = c(1,20), ylim = c(1,50))

nP <- list(col=3:2, cex=c(2.0, 0.75), pch= 21:22,
           bg= c("light blue", "pink"),
           lab.cex = 0.75, lab.col = "tomato")
plot(d3, nodePar= nP, edgePar = list(col="gray", lwd=2), horiz = TRUE)

addE <- function(n) {
      if(!is.leaf(n)) {
        attr(n, "edgePar") <- list(p.col="plum")
        attr(n, "edgetext") <- paste(attr(n,"members"),"members")
      }
      n
}
d3e <- dendrapply(d3, addE)
plot(d3e, nodePar= nP)
plot(d3e, nodePar= nP, leaflab = "textlike")




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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-23 22:25 , Processed in 0.024552 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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