[Vegan-commits] r2544 - in branches/2.0: . R inst inst/doc man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jul 9 15:07:03 CEST 2013


Author: jarioksa
Date: 2013-07-09 15:07:03 +0200 (Tue, 09 Jul 2013)
New Revision: 2544

Added:
   branches/2.0/R/ordiArrowTextXY.R
Modified:
   branches/2.0/DESCRIPTION
   branches/2.0/R/betadisper.R
   branches/2.0/R/eigenvals.R
   branches/2.0/R/ordipointlabel.R
   branches/2.0/R/plot.cca.R
   branches/2.0/R/plot.envfit.R
   branches/2.0/R/print.betadisper.R
   branches/2.0/R/stressplot.R
   branches/2.0/R/text.cca.R
   branches/2.0/inst/ChangeLog
   branches/2.0/inst/doc/decision-vegan.Rnw
   branches/2.0/inst/doc/diversity-vegan.Rnw
   branches/2.0/inst/doc/intro-vegan.Rnw
   branches/2.0/inst/doc/veganjss.sty
   branches/2.0/man/adipart.Rd
   branches/2.0/man/betadisper.Rd
   branches/2.0/man/ordipointlabel.Rd
   branches/2.0/man/vegan-internal.Rd
Log:
Merge easy and clear fixes to vegan 2.0-8

* merge r2540: remove hard-coded inconsolata fonts.
* merge r2539: stressplot return data in input order.
* merge r2538: use expression(R^2) in stressplot.
* merge r2535, 2536: better positioning of arrow labels.
* merge r2533: ordipointlabel uses ordiArgAbsorber.
* merge r2504: notation in adipart.Rd.
* merge r2497: avoid visible ~ in .Rnw.
* merge r2484 thru 2486: betadisper fixes


Modified: branches/2.0/DESCRIPTION
===================================================================
--- branches/2.0/DESCRIPTION	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/DESCRIPTION	2013-07-09 13:07:03 UTC (rev 2544)
@@ -1,7 +1,7 @@
 Package: vegan
 Title: Community Ecology Package
 Version: 2.0-8
-Date: March 19, 2013
+Date: July 9, 2013
 Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, 
    Peter R. Minchin, R. B. O'Hara, Gavin L. Simpson, Peter Solymos, 
    M. Henry H. Stevens, Helene Wagner  

Modified: branches/2.0/R/betadisper.R
===================================================================
--- branches/2.0/R/betadisper.R	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/R/betadisper.R	2013-07-09 13:07:03 UTC (rev 2544)
@@ -18,6 +18,18 @@
         spMedNeg <- ordimedian(vectors, group, choices = axes[!pos])
         cbind(spMedPos, spMedNeg)
     }
+    ## inline function for centroids
+    centroidFUN <- function(vec, group) {
+        cent <- apply(vec, 2,
+                      function(x, group) tapply(x, INDEX = group, FUN = mean),
+                      group = group)
+        if(!is.matrix(cent)) { ## if only 1 group, cent is vector
+            cent <- matrix(cent, nrow = 1,
+                           dimnames = list(as.character(levels(group)),
+                           paste0("Dim", seq_len(NCOL(vec)))))
+        }
+        cent
+    }
     ## inline function for distance computation
     Resids <- function(x, c) {
         if(is.matrix(c))
@@ -69,7 +81,6 @@
         warning("Missing observations due to 'd' removed.")
     }
     x <- x + t(x)
-    storage.mode(x) <- "double"
     x <- dblcen(x)
     e <- eigen(-x/2, symmetric = TRUE)
     vectors <- e$vectors
@@ -84,7 +95,7 @@
     ## group centroids in PCoA space
     centroids <-
         switch(type,
-               centroid = apply(vectors, 2, function(x) tapply(x, group, mean)),
+               centroid = centroidFUN(vectors, group),
                median = spatialMed(vectors, group, pos)
                )
     ## for each of the groups, calculate distance to centroid for

Modified: branches/2.0/R/eigenvals.R
===================================================================
--- branches/2.0/R/eigenvals.R	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/R/eigenvals.R	2013-07-09 13:07:03 UTC (rev 2544)
@@ -28,7 +28,7 @@
     out
 }
 
-## squares of sdev 
+## squares of sdev
 `eigenvals.prcomp` <-
     function(x, ...)
 {
@@ -78,6 +78,13 @@
     out
 }
 
+## betadisper (vegan)
+`eigenvals.betadisper` <-  function(x, ...) {
+    out <- x$eig
+    class(out) <- "eigenvals"
+    out
+}
+
 ## dudi objects of ade4
 
 `eigenvals.dudi` <-
@@ -112,8 +119,8 @@
     class(out) <- "eigenvals"
     out
 }
-        
 
+
 `print.eigenvals` <-
     function(x, ...)
 {

Copied: branches/2.0/R/ordiArrowTextXY.R (from rev 2535, pkg/vegan/R/ordiArrowTextXY.R)
===================================================================
--- branches/2.0/R/ordiArrowTextXY.R	                        (rev 0)
+++ branches/2.0/R/ordiArrowTextXY.R	2013-07-09 13:07:03 UTC (rev 2544)
@@ -0,0 +1,27 @@
+### Location of the text at the point of the arrow. 'vect' are the
+### coordinates of the arrow heads, and 'labels' are the text used to
+### label these heads, '...' passes arguments (such as 'cex') to
+### strwidth() and strheight().
+`ordiArrowTextXY` <-
+    function (vect, labels, ...) 
+{
+    w <- strwidth(labels, ...)
+    h <- strheight(labels, ...)
+    ## slope of arrows
+    b <- vect[,2]/vect[,1]
+    ## offset based on string dimensions
+    off <- cbind(sign(vect[,1]) * (w/2 + h/4), 0.75 * h * sign(vect[,2]))
+    ## move the centre of the string to the continuation of the arrow
+    for(i in 1:nrow(vect)) {
+        move <- off[i,2] / b[i]
+        ## arrow points to the top/bottom of the text box
+        if (is.finite(move) && abs(move) <= abs(off[i, 1]))
+            off[i, 1] <- move
+        else {
+            ## arrow points to a side of the text box
+            move <- b[i] * off[i,1]
+            off[i, 2] <- move
+        }  
+    }
+    off + vect
+}

Modified: branches/2.0/R/ordipointlabel.R
===================================================================
--- branches/2.0/R/ordipointlabel.R	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/R/ordipointlabel.R	2013-07-09 13:07:03 UTC (rev 2544)
@@ -88,9 +88,13 @@
     sol <- optim(par = pos, fn = fn, gr = gr, method="SANN",
                  control=list(maxit=nit))
     if (!add)
-        points(xy, pch = pch, col = col, cex=cex, ...)
+        ##points(xy, pch = pch, col = col, cex=cex, ...)
+        ordiArgAbsorber(xy, pch = pch, col = col, cex = cex, FUN = points,
+                        ...)
     lab <- xy + makeoff(sol$par, box)
-    text(lab, labels=labels, col = col, cex = cex, font = font,  ...)
+    ##text(lab, labels=labels, col = col, cex = cex, font = font,  ...)
+    ordiArgAbsorber(lab, labels=labels, col = col, cex = cex, font = font,
+                    FUN = text, ...)
     pl <- list(points = xy)
     pl$labels <- lab
     attr(pl$labels, "font") <- font

Modified: branches/2.0/R/plot.cca.R
===================================================================
--- branches/2.0/R/plot.cca.R	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/R/plot.cca.R	2013-07-09 13:07:03 UTC (rev 2544)
@@ -93,7 +93,8 @@
         attr(g$biplot, "arrow.mul") <- mul
         arrows(0, 0, mul * g$biplot[, 1], mul * g$biplot[, 2], 
                length = 0.05, col = "blue")
-        text(1.1 * mul * g$biplot, rownames(g$biplot), col = "blue")
+        biplabs <- ordiArrowTextXY(mul * g$biplot, rownames(g$biplot))
+        text(biplabs, rownames(g$biplot), col = "blue")
         axis(3, at = c(-mul, 0, mul), labels = rep("", 3), col = "blue")
         axis(4, at = c(-mul, 0, mul), labels = c(-1, 0, 1), col = "blue")
     }

Modified: branches/2.0/R/plot.envfit.R
===================================================================
--- branches/2.0/R/plot.envfit.R	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/R/plot.envfit.R	2013-07-09 13:07:03 UTC (rev 2544)
@@ -59,51 +59,67 @@
             ax <- -c(-1, 0, 1) * arrow.mul * maxarr
         }
         vect <- arrow.mul * vect
-        vtext <- sweep(1.1 * vect, 2, at, "+")
         vect <- sweep(vect, 2, at, "+")
+        if (add) {
+            vtext <- ordiArrowTextXY(vect, labs$v, ...)
+            vtext <- sweep(vtext, 2, at, "+")
+        }
     }
     if (!add) {
-        plot.new() ## needed for string widths and heights
-        if(!is.null(vect)) {
-            ## compute axis limits allowing space for labels
-            sw <- strwidth(labs$v, ...)
+        plot.new()
+        ## needed for string widths and heights We need dimensions to
+        ## fit completely the names of vectors and factors with no
+        ## clipping at axes. If there are (1) factors and vectors, we
+        ## need to adjust arrow lengths, if there are (2) only factors
+        ## or only vectors, we can use their scores directly. After
+        ## finding the scores, we must expand the scores by string
+        ## widths and heights. The expansion can be only estimated
+        ## after setting plot.window with its xlim and ylim, but we
+        ## need to find xlim and ylim to set the plot.window...
+
+        if(is.null(vect) || is.null(x$factors)) {
+            ## Only factors or vectors: set preliminary plot.window
+            xstack <- rbind(vect, x$factors$centroids)
+            plot.window(xlim = range(xstack[,1], at[1]),
+                        ylim = range(xstack[,2], at[2]),
+                        asp = 1, ...)
+        } else {
+            ## Both vectors and factors: set preliminary plot.window
+            ## from factors only and and find arrow.mul (which is
+            ## otherwise ## arrow.mul = 1)
+            plot.window(xlim = range(x$factors$centroids[,1], at[1]),
+                        ylim = range(x$factors$centroids[,2], at[2]),
+                        asp = 1, ...)
+            vfill <- 0.75
+            arrow.mul <- ordiArrowMul(vect, at = at, fill = 1)
+            vect <- arrow.mul * vect
+        }
+        ## Get string dimensions (width/2, height)
+        sw <- strwidth(c(labs$v, labs$f), ...) / 2
+        sh <- strheight(c(labs$v, labs$f), ...)
+        ## Reset limits
+        xstack <- rbind(x$factors$centroids, vect)
+        xlim <- range(xstack[,1] + sw, xstack[,2] - sw)
+        ylim <- range(xstack[,2] + sh, xstack[,2] - sh)
+        plot.window(xlim = xlim, ylim = ylim, asp = 1, ...)
+        ## Re-evaluate arrow.mul, set its text and re-evaluate limits again 
+        if (!is.null(vect)) {
+            arrow.mul <- ordiArrowMul(vect, at = at, fill = 1)
+            vect <- arrow.mul * vect
+            vtext <- ordiArrowTextXY(vect, labs$v, ...)
+            sw <- strwidth(labs$v, ...) / 2
             sh <- strheight(labs$v, ...)
-            xlim <- range(at[1], vtext[,1] + sw, vtext[,1] - sw)
-            ylim <- range(at[2], vtext[,2] + sh, vtext[,2] - sh)
-            if(!is.null(x$factors)) {
-                ## if factors, also need to consider them
-                sw <- strwidth(labs$f, ...)
-                sh <- strheight(labs$f, ...)
-                xlim <- range(xlim, x$factors$centroids[, choices[1]] + sw,
-                              x$factors$centroids[, choices[1]] - sw)
-                ylim <- range(ylim, x$factors$centroids[, choices[2]] + sh,
-                              x$factors$centroids[, choices[2]] - sh)
-            }
-            ## these plotting calls will prob. generate warnings
-            ## because of passing ... everywhere. localFoo needed?
+            xlim <- range(xlim, vtext[,1] + sw, vtext[,1] - sw)
+            ylim <- range(xlim, vtext[,2] + sh, vtext[,2] - sh)
             plot.window(xlim = xlim, ylim = ylim, asp = 1, ...)
-            axis(side = 1, ...)
-            axis(side = 2, ...)
-            box(...)
-            alabs <- colnames(vect)
-            title(..., ylab = alabs[2], xlab = alabs[1])
-        } else if (!is.null(x$factors)) {
-            sw <- strwidth(labs$f, ...)
-            sh <- strheight(labs$f, ...)
-            xlim <- range(at[1], x$factors$centroids[, choices[1]] + sw,
-                          x$factors$centroids[, choices[1]] - sw)
-            ylim <- range(at[2], x$factors$centroids[, choices[2]] + sh,
-                          x$factors$centroids[, choices[2]] - sh)
-            ## these plotting calls will prob. generate warnings
-            ## because of passing ... everywhere. localFoo needed?
-            plot.window(xlim = xlim, ylim = ylim, asp = 1, ...)
-            axis(side = 1, ...)
-            axis(side = 2, ...)
-            box(...)
-            alabs <- colnames(x$factors$centroids[, choices, drop = FALSE])
-            title(..., ylab = alabs[2], xlab = alabs[1])
-        } else stop("Nothing to plot")
+        }
+        axis(side = 1, ...)
+        axis(side = 2, ...)
+        box(...)
+        alabs <- colnames(vect)
+        title(..., ylab = alabs[2], xlab = alabs[1])
     }
+    
     if (!is.null(vect)) {
         arrows(at[1], at[2], vect[, 1], vect[, 2], len = 0.05,
                col = col)

Modified: branches/2.0/R/print.betadisper.R
===================================================================
--- branches/2.0/R/print.betadisper.R	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/R/print.betadisper.R	2013-07-09 13:07:03 UTC (rev 2544)
@@ -1,6 +1,9 @@
 `print.betadisper` <- function(x, digits = max(3, getOption("digits") - 3),
-                             ...)
+                               ...)
 {
+    ## limit number of eignvals to 8
+    ax.lim <- 8
+    ##
     cat("\n")
     writeLines(strwrap("Homogeneity of multivariate dispersions\n",
                        prefix = "\t"))
@@ -9,10 +12,12 @@
     cat(paste("\nNo. of Positive Eigenvalues:", sum(x$eig > 0)))
     cat(paste("\nNo. of Negative Eigenvalues:", sum(x$eig < 0)))
     cat("\n\n")
-    writeLines(strwrap("Average distance to centroid:\n"))
+    type <- ifelse(isTRUE(all.equal(attr(x, "type"), "median")),
+                   "medoid", "centroid")
+    writeLines(strwrap(paste0("Average distance to ", type, ":\n")))
     print.default(tapply(x$distances, x$group, mean), digits = digits)
     cat("\n")
     writeLines(strwrap("Eigenvalues for PCoA axes:\n"))
-    print.default(round(x$eig, digits = digits))
+    print.default(round(x$eig[seq_len(ax.lim)], digits = digits))
     invisible(x)
 }

Modified: branches/2.0/R/stressplot.R
===================================================================
--- branches/2.0/R/stressplot.R	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/R/stressplot.R	2013-07-09 13:07:03 UTC (rev 2544)
@@ -61,10 +61,15 @@
     ## Stress as R2
     rstress <- 1 - object$stress^2
     ralscal <- if(object$iregn == 3) ralscal/2 else ralscal/object$ngrp
-    lab <- paste("Non-metric fit, R2 =", format(rstress, digits=3),
-                 "\nLinear fit, R2 =", format(ralscal, digits=3))
-    text(min(x), 0.95*max(y), lab, pos=4)
-    invisible(list("x" = x, "y" = y, "yf" = yf))
+    Rst <- format(rstress, digits = 3)
+    Ral <- format(ralscal, digits = 3)
+    lab1 <- bquote("Non-metric fit, " * R^2 == .(Rst))
+    lab2 <- bquote("Linear fit, " * R^2 == .(Ral))
+    text(min(x), 0.95*max(y), lab1, pos=4)
+    text(min(x), 0.95*max(y) - strheight(lab1), lab2, pos=4)
+    ## we want to have invisible return lists in the input order
+    o <- order(object$jidx, object$iidx)
+    invisible(list("x" = x[o], "y" = y[o], "yf" = yf[o]))
 }
     
 `stressplot.default` <-
@@ -87,8 +92,11 @@
     plot(shep, pch = pch, col = p.col, xlab = "Observed Dissimilarity",
          ylab = "Ordination Distance", ...)
     lines(shep$x, shep$yf, type = "S", col = l.col, lwd = lwd, ...)
-    lab <- paste("Non-metric fit, R2 =", format(rstress, digits=3),
-               "\nLinear fit, R2 =", format(ralscal, digits=3))
-    text(min(shep$x), 0.95*max(shep$y), lab, pos=4)
+    Rst <- format(rstress, digits = 3)
+    Ral <- format(ralscal, digits = 3)
+    lab1 <- bquote("Non-metric fit, " * R^2 == .(Rst))
+    lab2 <- bquote("Linear fit, " * R^2 == .(Ral))
+    text(min(shep$x), 0.95*max(shep$y), lab1, pos=4)
+    text(min(shep$x), 0.95*max(shep$y) - strheight(lab1), lab2, pos=4)
     invisible(shep)
 }

Modified: branches/2.0/R/text.cca.R
===================================================================
--- branches/2.0/R/text.cca.R	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/R/text.cca.R	2013-07-09 13:07:03 UTC (rev 2544)
@@ -29,7 +29,7 @@
         pts <- pts * arrow.mul
         arrows(0, 0, pts[, 1], pts[, 2], length = head.arrow,
                ...)
-        pts <- pts * 1.1
+        pts <- ordiArrowTextXY(pts, rownames(pts), ...)
         if (axis.bp) {
             axis(side = 3, at = c(-arrow.mul, 0, arrow.mul),
                  labels = rep("", 3))

Modified: branches/2.0/inst/ChangeLog
===================================================================
--- branches/2.0/inst/ChangeLog	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/inst/ChangeLog	2013-07-09 13:07:03 UTC (rev 2544)
@@ -4,9 +4,15 @@
 
 Version 2.0-8 (opened March 19, 2013)
 
-	* version 2.0-7 may be the last release in 2.0 series, and the
-	next release version may be a major upgrade 2.2-0 (this
-	information may change if there is a need for a 2.0 release).
+	* merge r2540: remove hard-coded inconsolata fonts.
+	* merge r2539: stressplot return data in input order.
+	* merge r2538: use expression(R^2) in stressplot.
+	* merge r2535, 2536: better positioning of arrow labels.
+	* merge r2533: ordipointlabel uses ordiArgAbsorber.
+	* merge r2504: notation in adipart.Rd.
+	* merge r2497: avoid visible ~ in .Rnw.
+	* merge r2484 thru 2486: betadisper fixes (centroid with one
+	group, call it medoid).
 	
 Version 2.0-7 (released March 19, 2013)
 

Modified: branches/2.0/inst/doc/decision-vegan.Rnw
===================================================================
--- branches/2.0/inst/doc/decision-vegan.Rnw	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/inst/doc/decision-vegan.Rnw	2013-07-09 13:07:03 UTC (rev 2544)
@@ -8,6 +8,7 @@
 %\usepackage[utf8x]{inputenc}
 %\usepackage[T1]{fontenc}
 \usepackage{sidecap}
+\usepackage[english]{babel} % kluge to avoid visible ~ in Figure~1.
 \renewcommand{\floatpagefraction}{0.8}
 \renewcommand{\cite}{\citep}
 

Modified: branches/2.0/inst/doc/diversity-vegan.Rnw
===================================================================
--- branches/2.0/inst/doc/diversity-vegan.Rnw	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/inst/doc/diversity-vegan.Rnw	2013-07-09 13:07:03 UTC (rev 2544)
@@ -8,8 +8,8 @@
 \usepackage{sidecap}
 \usepackage{amsmath}
 \usepackage{amssymb} % \gtrapprox
+\usepackage[english]{babel} % kluge to avoid visible ~ in Figure~1
 
-
 \title{Vegan: ecological diversity} \author{Jari Oksanen} 
 
 \Abstract{ This document explains diversity related methods in

Modified: branches/2.0/inst/doc/intro-vegan.Rnw
===================================================================
--- branches/2.0/inst/doc/intro-vegan.Rnw	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/inst/doc/intro-vegan.Rnw	2013-07-09 13:07:03 UTC (rev 2544)
@@ -7,6 +7,7 @@
 \usepackage[T1]{fontenc}
 \usepackage{sidecap}
 \usepackage{amsmath}
+\usepackage[english]{babel} % kluge to avoid visible ~ in Figure~1
 
 \renewcommand{\floatpagefraction}{0.8}
 

Modified: branches/2.0/inst/doc/veganjss.sty
===================================================================
--- branches/2.0/inst/doc/veganjss.sty	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/inst/doc/veganjss.sty	2013-07-09 13:07:03 UTC (rev 2544)
@@ -17,8 +17,9 @@
   \textbf{\large \thesubsection. #2} \nopagebreak
   \vskip \postSskip \nopagebreak}
 
-%% use inconsolata fonts for code and examples 
-\usepackage{inconsolata}
+%% do not use inconsolata fonts for code and examples: they are to be
+%% removed from CTAN 
+%\usepackage{inconsolata}
 %% smaller examples
 \renewenvironment{Schunk}{\par\small}{}
 

Modified: branches/2.0/man/adipart.Rd
===================================================================
--- branches/2.0/man/adipart.Rd	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/man/adipart.Rd	2013-07-09 13:07:03 UTC (rev 2544)
@@ -93,7 +93,7 @@
   At the highest sampling level, the diversity components are calculated
   as \deqn{\beta_m  = \gamma -  \alpha_m}{beta_m = gamma -  alpha_m} For
   each  lower   sampling  level   as  \deqn{\beta_i  =   \alpha_{i+1}  -
-  \alpha_i}{beta_i =  alpha_i+1 - alpha_i} Then,  the additive partition
+  \alpha_i}{beta_i =  alpha_(i+1) - alpha_i} Then,  the additive partition
   of diversity is \deqn{\gamma  = \alpha_1 + \sum_{i=1}^m \beta_i}{gamma
   = alpha_1 + sum(beta_i)}
 

Modified: branches/2.0/man/betadisper.Rd
===================================================================
--- branches/2.0/man/betadisper.Rd	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/man/betadisper.Rd	2013-07-09 13:07:03 UTC (rev 2544)
@@ -6,6 +6,7 @@
 \alias{plot.betadisper}
 \alias{boxplot.betadisper}
 \alias{TukeyHSD.betadisper}
+\alias{eigenvals.betadisper}
 \alias{ordimedian}
 
 \title{Multivariate homogeneity of groups dispersions (variances)}
@@ -33,6 +34,8 @@
 \method{scores}{betadisper}(x, display = c("sites", "centroids"),
        choices = c(1,2), \dots)
 
+\method{eigenvals}{betadisper}(x, \dots)
+
 \method{plot}{betadisper}(x, axes = c(1,2), cex = 0.7, hull = TRUE,
      ylab, xlab, main, sub, \dots)
 
@@ -160,6 +163,8 @@
   The \code{boxplot} function invisibly returns a list whose components
   are documented in \code{\link[graphics]{boxplot}}.
 
+  \code{eigenvals.betadisper} returns a named vector of eigenvalues.
+
   \code{TukeyHSD.betadisper} returns a list. See \code{\link{TukeyHSD}}
   for further details.
 
@@ -251,6 +256,23 @@
 ## Draw a boxplot of the distances to centroid for each group
 boxplot(mod)
 
+## `scores` and `eigenvals` also work
+scrs <- scores(mod)
+str(scrs)
+head(scores(mod, 1:4, display = "sites"))
+# group centroids/medoids 
+scores(mod, 1:4, display = "centroids")
+# eigenvalues from the underlying principal coordinates analysis
+eigenvals(mod) 
+
+## try out bias correction; compare with mod3
+(mod3B <- betadisper(dis, groups, type = "median", bias.adjust=TRUE))
+
+## should always work for a single group
+group <- factor(rep("grazed", NROW(varespec)))
+(tmp <- betadisper(dis, group, type = "median"))
+(tmp <- betadisper(dis, group, type = "centroid"))
+
 ## simulate missing values in 'd' and 'group'
 ## using spatial medians
 groups[c(2,20)] <- NA
@@ -272,9 +294,6 @@
 boxplot(mod3)
 plot(TukeyHSD(mod3))
 
-## try out bias correction; compare with mod3
-(mod3B <- betadisper(dis, groups, type = "median", bias.adjust=TRUE))
-
 }
 \keyword{methods}
 \keyword{multivariate}

Modified: branches/2.0/man/ordipointlabel.Rd
===================================================================
--- branches/2.0/man/ordipointlabel.Rd	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/man/ordipointlabel.Rd	2013-07-09 13:07:03 UTC (rev 2544)
@@ -75,6 +75,14 @@
 data(dune)
 ord <- cca(dune)
 ordipointlabel(ord)
+
+## set scaling - should be no warnings!
+ordipointlabel(ord, scaling = 1)
+
+## plot then add
+plot(ord, scaling = 3, type = "n")
+ordipointlabel(ord, display = "species", scaling = 3, add = TRUE)
+ordipointlabel(ord, display = "sites", scaling = 3, add = TRUE)
 }
 \keyword{ hplot }
 \keyword{ aplot }

Modified: branches/2.0/man/vegan-internal.Rd
===================================================================
--- branches/2.0/man/vegan-internal.Rd	2013-07-08 03:19:38 UTC (rev 2543)
+++ branches/2.0/man/vegan-internal.Rd	2013-07-09 13:07:03 UTC (rev 2544)
@@ -8,6 +8,7 @@
 \alias{ordiTerminfo}
 \alias{pasteCall}
 \alias{ordiArrowMul}
+\alias{oridArrowTextXY}
 \alias{ordiArgAbsorber}
 \alias{veganCovEllipse}
 \alias{hierParseFormula}
@@ -26,6 +27,7 @@
 ordiNAexclude(x, excluded)
 ordiNApredict(omit, x)
 ordiArrowMul(x, at = c(0,0), fill = 0.75)
+ordiArrowTextXY(vect, labels, ...)
 ordiArgAbsorber(..., shrink, origin, scaling, triangular,
                 display, choices, const, FUN)
 centroids.cca(x, mf, wt)
@@ -62,6 +64,11 @@
   \code{ordiNApredict} puts pads the result object with these or with
   WA scores similarly as \code{\link{napredict}}.
 
+  \code{ordiArrowMul} finds a multiplier to scale a bunch of arrows to
+  fill an ordination plot, and \code{ordiArrowTextXY} finds the
+  coordinates for labels of these arrows.  See \code{\link{envfit}}
+  for an application.
+
   \code{ordiArgAbsorber} absorbs arguments of \code{\link{scores}}
   function of \pkg{vegan} so that these do not cause superfluous
   warnings in graphical function \code{FUN}. If you implement



More information about the Vegan-commits mailing list