[Vegan-commits] r1023 - in pkg/vegan: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Sep 25 07:51:55 CEST 2009


Author: jarioksa
Date: 2009-09-25 07:51:51 +0200 (Fri, 25 Sep 2009)
New Revision: 1023

Modified:
   pkg/vegan/R/plot.meandist.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/mrpp.Rd
Log:
plot.meandist draws now histogram plots as an alternative to dendrograms

Modified: pkg/vegan/R/plot.meandist.R
===================================================================
--- pkg/vegan/R/plot.meandist.R	2009-09-23 06:51:30 UTC (rev 1022)
+++ pkg/vegan/R/plot.meandist.R	2009-09-25 05:51:51 UTC (rev 1023)
@@ -1,19 +1,37 @@
 `plot.meandist` <-
-    function(x, cluster = "average", ylim, ...) 
+    function(x, kind = c("dendrogram", "histogram"),  cluster = "average", ylim,
+             axes = TRUE, ...) 
 {
+    kind <- match.arg(kind)
     n <- attr(x, "n")
-    cl <- hclust(as.dist(x), method = cluster, members = n)
-    cl <- as.dendrogram(cl, hang = 0)
-    w <- diag(x)[labels(cl)]
-    tr <- unlist(dendrapply(cl, function(n) attr(n, "height")))
-    root <- attr(cl, "height")
-    if (missing(ylim))
-        ylim <- range(c(w, tr, root), na.rm = TRUE)
-    plot(cl, ylim = ylim, leaflab = "none", ...)
-    for (i in 1:length(w)) segments(i, tr[i], i, w[i])
-    pos <- ifelse(w < tr, 1, 3)
-    pos[is.na(pos)] <- 1
-    w[is.na(w)] <- tr[is.na(w)]
-    text(1:length(w), w, labels = labels(cl), pos = pos, srt = 0)
+    if (kind == "dendrogram") {
+        cl <- hclust(as.dist(x), method = cluster, members = n)
+        cl <- as.dendrogram(cl, hang = 0)
+        w <- diag(x)[labels(cl)]
+        tr <- unlist(dendrapply(cl, function(n) attr(n, "height")))
+        root <- attr(cl, "height")
+        if (missing(ylim))
+            ylim <- range(c(w, tr, root), na.rm = TRUE)
+        plot(cl, ylim = ylim, leaflab = "none", axes = axes, ...)
+        for (i in 1:length(w)) segments(i, tr[i], i, w[i])
+        pos <- ifelse(w < tr, 1, 3)
+        pos[is.na(pos)] <- 1
+        w[is.na(w)] <- tr[is.na(w)]
+        text(1:length(w), w, labels = labels(cl), pos = pos, srt = 0)
+    } else {
+        w <- diag(x)
+        tr <- rep(summary(x)$B, length(w))
+        if (missing(ylim))
+            ylim <- range(c(w, tr), na.rm = TRUE)
+        plot(1:length(w), tr, ylim = ylim, axes = FALSE, xlab = "", ylab = "",
+             type = "l", ...)
+        if (axes)
+            axis(2, ...)
+        for (i in 1:length(w)) segments(i, tr, i, w[i])
+        pos <- ifelse(w < tr, 1, 3)
+        pos[is.na(pos)] <- 1
+        text(1:length(w), w, labels = names(n), pos = pos, srt = 0,
+             xpd = TRUE, ...)
+    }
 }
 

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-09-23 06:51:30 UTC (rev 1022)
+++ pkg/vegan/inst/ChangeLog	2009-09-25 05:51:51 UTC (rev 1023)
@@ -4,6 +4,11 @@
 
 Version 1.16-30 (opened September 18, 2009) 
 
+	* meandist: plot method has a new alternative of drawing
+	histograms (van Sickle 1997) as an alternative to dendrograms. A
+	histogram connects groups at theri within-cluster dissimilarity
+	level to the average between-cluster dissimilarity.
+
 	* oecosimu: gained new keyword 'alternative' for "two.sided",
 	"less" and "greater" one-sided tests.
 	

Modified: pkg/vegan/man/mrpp.Rd
===================================================================
--- pkg/vegan/man/mrpp.Rd	2009-09-23 06:51:30 UTC (rev 1022)
+++ pkg/vegan/man/mrpp.Rd	2009-09-25 05:51:51 UTC (rev 1023)
@@ -18,7 +18,8 @@
      weight.type = 1, strata)
 meandist(dist, grouping, ...)
 \method{summary}{meandist}(object, ...)
-\method{plot}{meandist}(x, cluster = "average", ylim, ...)
+\method{plot}{meandist}(x, kind = c("dendrogram", "histogram"),  cluster = "average", 
+     ylim, axes = TRUE, ...)
 }
 
 \arguments{
@@ -40,10 +41,13 @@
     produced by functions \code{\link{dist}}, \code{\link{vegdist}} or
     \code{\link{designdist}}.}.
   \item{object, x}{A \code{meandist} result object.}
+  \item{kind}{Draw a dendrogram or a histogram; see Details.}
   \item{cluster}{A clustering method for the \code{\link{hclust}}
-    function. Any \code{hclust} method can be used, but perhaps only
+    function for \code{kind = "dendrogram"}. 
+    Any \code{hclust} method can be used, but perhaps only
     \code{"average"} and \code{"single"} make sense.}
   \item{ylim}{Limits for vertical axes (optional).}
+  \item{axes}{Draw scale for the vertical axis.}
   \item{\dots}{Further arguments passed to functions.}
 }
 
@@ -101,11 +105,16 @@
 with all \code{weight.type} options and the classification
 strength. The function does not allow significance tests for these
 statistics, but you must use \code{mrpp} with appropriate
-\code{weight.type}. Function \code{plot} draws a dendrogram of the
-result matrix with given \code{cluster} method (see
-\code{\link{hclust}}). The terminal segments hang to within-cluster
-dissimilarity. If some of the clusters is more heterogeneous than the
-combined class, the leaf segment is reversed.  
+\code{weight.type}.  Function \code{plot} draws a dendrogram or a
+histogram of the result matrix based on the within-group and between
+group dissimilarities. The dendrogram is given with the \code{cluster}
+argument which is passed to \code{\link{hclust}}. The terminal
+segments hang to within-cluster dissimilarity. If some of the clusters
+is more heterogeneous than the combined class, the leaf segment is
+reversed.  The histogram is similar as the graphics used by Van Sickle
+(1997): horizontal line is drawn at the level of mean between-cluster
+dissimilarity and vertical lines connect within-cluster
+dissimilarities to this line.  
 }
 
 \value{



More information about the Vegan-commits mailing list