[Vegan-commits] r1697 - in branches/1.17: . R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Aug 7 19:32:53 CEST 2011


Author: jarioksa
Date: 2011-08-07 19:32:53 +0200 (Sun, 07 Aug 2011)
New Revision: 1697

Added:
   branches/1.17/NAMESPACE
   branches/1.17/man/ordiarrows.Rd
Modified:
   branches/1.17/DESCRIPTION
   branches/1.17/R/anova.cca.R
   branches/1.17/R/anova.ccabyterm.R
   branches/1.17/R/anova.ccanull.R
   branches/1.17/R/betadiver.R
   branches/1.17/R/bstick.cca.R
   branches/1.17/R/calibrate.cca.R
   branches/1.17/R/capscale.R
   branches/1.17/R/deviance.cca.R
   branches/1.17/R/deviance.rda.R
   branches/1.17/R/goodness.cca.R
   branches/1.17/R/goodness.rda.R
   branches/1.17/R/make.cepnames.R
   branches/1.17/R/metaMDSrotate.R
   branches/1.17/R/ordiellipse.R
   branches/1.17/R/ordihull.R
   branches/1.17/R/ordilabel.R
   branches/1.17/R/ordiplot.R
   branches/1.17/R/ordiplot3d.R
   branches/1.17/R/ordiresids.R
   branches/1.17/R/ordirgl.R
   branches/1.17/R/ordispider.R
   branches/1.17/R/ordixyplot.R
   branches/1.17/R/predict.cca.R
   branches/1.17/R/predict.rda.R
   branches/1.17/R/screeplot.cca.R
   branches/1.17/R/swan.R
   branches/1.17/R/zzz.R
   branches/1.17/inst/ChangeLog
   branches/1.17/man/RsquareAdj.Rd
   branches/1.17/man/beals.Rd
   branches/1.17/man/betadiver.Rd
   branches/1.17/man/deviance.cca.Rd
   branches/1.17/man/make.cepnames.Rd
   branches/1.17/man/ordihull.Rd
   branches/1.17/man/ordilabel.Rd
   branches/1.17/man/predict.cca.Rd
   branches/1.17/man/screeplot.cca.Rd
   branches/1.17/man/varpart.Rd
Log:
merged minor fixes since 1.17-11 (r1652 to 1695) but no monoMDS or permute dependence (see ChangeLog)

Modified: branches/1.17/DESCRIPTION
===================================================================
--- branches/1.17/DESCRIPTION	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/DESCRIPTION	2011-08-07 17:32:53 UTC (rev 1697)
@@ -1,7 +1,7 @@
 Package: vegan
 Title: Community Ecology Package
-Version: 1.17-11
-Date: June 14, 2011
+Version: 1.17-12
+Date: August 7, 2011
 Author: Jari Oksanen, F. Guillaume Blanchet, Roeland Kindt, Pierre Legendre, 
    R. B. O'Hara, Gavin L. Simpson, Peter Solymos, M. Henry H. Stevens, 
    Helene Wagner  

Copied: branches/1.17/NAMESPACE (from rev 1695, pkg/vegan/NAMESPACE)
===================================================================
--- branches/1.17/NAMESPACE	                        (rev 0)
+++ branches/1.17/NAMESPACE	2011-08-07 17:32:53 UTC (rev 1697)
@@ -0,0 +1,4 @@
+## compiled code
+useDynLib(vegan)
+## Export
+exportPattern(".")

Modified: branches/1.17/R/anova.cca.R
===================================================================
--- branches/1.17/R/anova.cca.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/anova.cca.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -2,7 +2,8 @@
     function (object, alpha = 0.05, beta = 0.01, step = 100, perm.max = 9999, 
               by = NULL, ...) 
 {
-    if (is.null(object$CA) || is.null(object$CCA))
+    if (is.null(object$CA) || is.null(object$CCA) ||
+        object$CCA$rank == 0 || object$CA$rank == 0)
         return(anova.ccanull(object))
     perm.max <- max(step-1, perm.max)
     if (perm.max %% step == 0)

Modified: branches/1.17/R/anova.ccabyterm.R
===================================================================
--- branches/1.17/R/anova.ccabyterm.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/anova.ccabyterm.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -26,7 +26,7 @@
     df[ntrm:(ntrm + 1)] <- sim$df
     chi[ntrm:(ntrm + 1)] <- sim$chi
     if (!is.null(object$call$data))
-        modelframe <- ordiGetData(object$call, NULL)
+        modelframe <- ordiGetData(object$call, globalenv())
     else
         modelframe <- NULL
     for (.ITRM in ntrm:2) {

Modified: branches/1.17/R/anova.ccanull.R
===================================================================
--- branches/1.17/R/anova.ccanull.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/anova.ccanull.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -5,7 +5,7 @@
     function(object, ...)
 {
     table <- matrix(0, nrow = 2, ncol = 5)
-    if (is.null(object$CA)) {
+    if (object$CA$rank == 0) {
         table[1,] <- c(object$CCA$qrank, object$CCA$tot.chi, NA, 0, NA)
         table[2,] <- c(0,0,NA,NA,NA)
     }
@@ -18,9 +18,9 @@
                           if (inherits(object, "rda")) "Var" else "Chisq", 
                           "F", "N.Perm", "Pr(>F)")
     table <- as.data.frame(table)
-    if (is.null(object$CA))
+    if (object$CA$rank == 0)
         head <- "No residual component\n"
-    else if (is.null(object$CCA))
+    else if (is.null(object$CCA) || object$CCA$rank == 0)
         head <- "No constrained component\n"
     else
         head <- c("!!!!! ERROR !!!!!\n")

Modified: branches/1.17/R/betadiver.R
===================================================================
--- branches/1.17/R/betadiver.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/betadiver.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -1,6 +1,14 @@
 `betadiver` <-
-    function(x, index = NA, order = FALSE, help = FALSE,  ...)
+    function(x, method = NA, order = FALSE, help = FALSE,  ...)
 {
+    ## 'index' was renamed to 'method' in vegan 1.90-1 for dist()
+    ## compatibility. Below we implement backward compatibility (with
+    ## warning) for 'index'.
+    dots <- match.call(expand.dots = FALSE)$...
+    if (any(k <- pmatch(names(dots), "index", nomatch = FALSE))) {
+        warning("argument 'index' deprecated: use 'method'")
+        method <- dots[[which(k==1)]]
+    }
     beta <- list("w"="(b+c)/(2*a+b+c)", "-1"="(b+c)/(2*a+b+c)", "c"="(b+c)/2",
                  "wb"="b+c", "r"="2*b*c/((a+b+c)^2-2*b*c)",
                  "I"="log(2*a+b+c)-2*a*log(2)/(2*a+b+c)-((a+b)*log(a+b)+(a+c)*log(a+c))/(2*a+b+c)",
@@ -33,14 +41,14 @@
     N <- length(S)
     b <- as.dist(matrix(rep(S, N), nrow=N)) - a
     c <- as.dist(matrix(rep(S, each=N), nrow=N)) - a
-    if (is.na(index) || is.null(index) || is.logical(index) && !index) {
+    if (is.na(method) || is.null(method) || is.logical(method) && !method) {
         out <- list(a = a, b = b, c = c)
         class(out) <- "betadiver"
         return(out)
     }
-    out <- eval(parse(text=beta[[index]]))
+    out <- eval(parse(text=beta[[method]]))
     out <- as.dist(out)
-    attr(out, "method") <- paste("beta", names(beta[index]), sep=".")
+    attr(out, "method") <- paste("beta", names(beta[method]), sep=".")
     attr(out, "call") <- match.call()
     out
 }

Modified: branches/1.17/R/bstick.cca.R
===================================================================
--- branches/1.17/R/bstick.cca.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/bstick.cca.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -3,7 +3,7 @@
 {
     if(!inherits(n, c("rda", "cca")))
         stop("'n' not of class \"cca\" or \"rda\"")
-    if(!is.null(n$CCA))
+    if(!is.null(n$CCA) && n$CCA$rank > 0)
         stop("'bstick' only for unconstrained models.")
     ## No idea how to define bstick for capscale with negative
     ## eigenvalues

Modified: branches/1.17/R/calibrate.cca.R
===================================================================
--- branches/1.17/R/calibrate.cca.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/calibrate.cca.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -3,7 +3,7 @@
 {
     if (!is.null(object$pCCA))
         stop("does not work with conditioned (partial) models")
-    if (is.null(object$CCA))
+    if (is.null(object$CCA) || object$CCA$rank == 0)
         stop("needs constrained model")
     if (object$CCA$rank < object$CCA$qrank)
         stop("rank of constraints is higher than rank of dependent data")

Modified: branches/1.17/R/capscale.R
===================================================================
--- branches/1.17/R/capscale.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/capscale.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -16,7 +16,8 @@
     ## The following line was eval'ed in environment(formula), but
     ## that made update() fail. Rethink the line if capscale() fails
     ## mysteriously at this point.
-    X <- eval(formula[[2]]) #, environment(formula))
+    X <- eval(formula[[2]], envir=parent.frame(),
+              enclos = environment(formula))
     if (!inherits(X, "dist")) {
         comm <- X
         dfun <- match.fun(dfun)

Modified: branches/1.17/R/deviance.cca.R
===================================================================
--- branches/1.17/R/deviance.cca.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/deviance.cca.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -1,8 +1,5 @@
 `deviance.cca` <-
     function(object, ...)
 {
-    if (is.null(object$CA))
-        0
-    else
-        object$CA$tot.chi * object$grand.tot
+    object$CA$tot.chi * object$grand.tot
 }

Modified: branches/1.17/R/deviance.rda.R
===================================================================
--- branches/1.17/R/deviance.rda.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/deviance.rda.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -1,8 +1,5 @@
 `deviance.rda` <-
     function(object, ...)
 {
-    if (is.null(object$CA))
-        0
-    else
-        object$CA$tot.chi * (nrow(object$CA$Xbar) - 1)
+    object$CA$tot.chi * (nrow(object$CA$Xbar) - 1)
 }

Modified: branches/1.17/R/goodness.cca.R
===================================================================
--- branches/1.17/R/goodness.cca.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/goodness.cca.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -6,7 +6,7 @@
     model <- match.arg(model)
     if (is.null(object$CCA)) 
         model <- "CA"
-    if (is.null(object[[model]])) 
+    if (is.null(object[[model]]) || object[[model]]$rank == 0) 
         stop("model ", model, " is not available")
     statistic <- match.arg(statistic)
     display <- match.arg(display)

Modified: branches/1.17/R/goodness.rda.R
===================================================================
--- branches/1.17/R/goodness.rda.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/goodness.rda.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -9,7 +9,7 @@
         stop("display = \"species\" not available for 'capscale'")
     if (is.null(object$CCA)) 
         model <- "CA"
-    if (is.null(object[[model]])) 
+    if (is.null(object[[model]]) || object[[model]]$rank == 0) 
         stop("model ", model, " is not available")
     statistic <- match.arg(statistic)
     cs <- weights(object, display = display)

Modified: branches/1.17/R/make.cepnames.R
===================================================================
--- branches/1.17/R/make.cepnames.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/make.cepnames.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -1,13 +1,20 @@
-"make.cepnames" <-
-    function (names) 
+`make.cepnames` <-
+    function (names, seconditem = FALSE) 
 {
+    ## make valid names
     names <- make.names(names, unique = FALSE)
+    ## remove trailing and duplicated dots
+    names <- gsub("\\.[\\.]+", ".", names)
+    names <- gsub("\\.$", "", names)
+    ## split by dots and take 4 letters of each element (if several)
     names <- lapply(strsplit(names, "\\."), function(x) if (length(x) > 1) 
                     substring(x, 1, 4) else x )
+    ## Take first and last element or 8 characters if only one element
     names <- unlist(lapply(names, function(x) if (length(x) > 1)
-                           paste(x[c(1, length(x))], collapse = "")
+                           paste(x[c(1, if(seconditem) 2 else length(x))], collapse = "")
                            else x))
     names <- abbreviate(names, 8)
+    ## Final clean-up
     names <- make.names(names, unique = TRUE)
     names
 }

Modified: branches/1.17/R/metaMDSrotate.R
===================================================================
--- branches/1.17/R/metaMDSrotate.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/metaMDSrotate.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -14,13 +14,6 @@
         stop(gettextf("function works only with univariate 'vec'"))
     if (!is.numeric(vec))
         stop(gettextf("'vec' must be numeric"))
-    ## scores must be orthogonal for the next loop to work
-    if (N > 2) {
-        pc <- prcomp(x)
-        x <- pc$x
-        if (!all(is.na(sp)))
-            sp <- sp %*% pc$rotation
-    }
     ## vectorfit finds the direction cosine. We rotate first axis to
     ## 'vec' which means that we make other axes orthogonal to 'vec'
     ## one by one
@@ -28,6 +21,14 @@
         keep <- !is.na(vec)
     else
         keep <- !logical(length(vec))
+    ## scores must be orthogonal for the next loop to work
+    if (N > 2) {
+        pc <- prcomp(x[keep,])
+        x <- x %*% pc$rotation
+        if (!all(is.na(sp)))
+            sp <- sp %*% pc$rotation
+    }
+    ## Rotation loop
     for (k in 2:N) {
         rot <- vectorfit(x[keep, c(1,k)], vec[keep], permutations=0)$arrows
         rot <- drop(rot)

Modified: branches/1.17/R/ordiellipse.R
===================================================================
--- branches/1.17/R/ordiellipse.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/ordiellipse.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -30,8 +30,10 @@
     res <- list()
     if (label)
         cntrs <- names <- NULL
+    ## Remove NA scores
+    kk <- complete.cases(pts)
     for (is in inds) {
-        gr <- out[groups == is]
+        gr <- out[groups == is & kk]
         if (length(gr) > 2) {
             X <- pts[gr, ]
             W <- w[gr]

Modified: branches/1.17/R/ordihull.R
===================================================================
--- branches/1.17/R/ordihull.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/ordihull.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -13,8 +13,10 @@
     out <- seq(along = groups)
     inds <- names(table(groups))
     res <- list()
+    ## Remove NA scores
+    kk <- complete.cases(pts)
     for (is in inds) {
-        gr <- out[groups == is]
+        gr <- out[groups == is & kk]
         if (length(gr) > 1) {
             X <- pts[gr, ]
             hpts <- chull(X)

Modified: branches/1.17/R/ordilabel.R
===================================================================
--- branches/1.17/R/ordilabel.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/ordilabel.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -1,5 +1,5 @@
 `ordilabel` <-
-    function(x, display, labels, choices = c(1,2), priority,
+    function(x, display, labels, choices = c(1,2), priority, select,
              cex = 0.8, fill = "white", border = NULL, col = NULL,
              xpd = TRUE, ...)
 {
@@ -8,7 +8,13 @@
     x <- scores(x, choices = choices, display = display, ...)
     if (missing(labels))
         labels <- rownames(x)
+    if (!missing(select)) {
+        x <- x[select, , drop = FALSE]
+        labels <- labels[select]
+    }
     if (!missing(priority)) {
+        if (!missing(select))
+            priority <- priority[select]
         ord <- order(priority)
         x <- x[ord, ]
         labels <- labels[ord]

Modified: branches/1.17/R/ordiplot.R
===================================================================
--- branches/1.17/R/ordiplot.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/ordiplot.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -1,13 +1,18 @@
 `ordiplot` <-
-    function (ord, choices = c(1, 2), type = "points", display, xlim, 
-              ylim, ...) 
+    function (ord, choices = c(1, 2), type = "points", display, xlim,
+              ylim, ...)
 {
-    if (!is.null(attr(ord, "class")) && (class(ord) == "decorana" || 
+    ## local functions to absorb non-par arguments of plot.default
+    localPoints <- function(..., log, frame.plot, panel.first,
+                            panel.last, axes) points(...)
+    localText <- function(..., log, frame.plot, panel.first,
+                          panel.last, axes) text(...)
+    if (!is.null(attr(ord, "class")) && (class(ord) == "decorana" ||
                                          any(class(ord) == "cca"))) {
-        if (missing(display)) 
-            out <- plot(ord, choices, type = type, xlim = xlim, 
+        if (missing(display))
+            out <- plot(ord, choices, type = type, xlim = xlim,
                         ylim = ylim, ...)
-        else out <- plot(ord, choices, type = type, display = display, 
+        else out <- plot(ord, choices, type = type, display = display,
                          xlim = xlim, ylim = ylim, ...)
     }
     else {
@@ -20,7 +25,7 @@
         else
             display <- match.arg(display, dplays, several.ok = TRUE)
         X <- Y <- NULL
-        if ("sites" %in% display) 
+        if ("sites" %in% display)
             X <- scores(ord, choices = choices, display = "sites")
         if ("species" %in% display) {
             options(show.error.messages = FALSE)
@@ -45,26 +50,23 @@
             return(invisible(pl))
         }
         tmp <- apply(rbind(X, Y), 2, range, na.rm=TRUE)
-        if (missing(xlim)) 
+        if (missing(xlim))
             xlim <- tmp[, 1]
-        if (missing(ylim)) 
+        if (missing(ylim))
             ylim <- tmp[, 2]
-        plot(tmp, xlim = xlim, ylim = ylim, asp = 1, type = "n", 
+        plot(tmp, xlim = xlim, ylim = ylim, asp = 1, type = "n",
              ...)
         if (type == "points") {
-            if (!is.null(X)) 
-                points(X, pch = 1, col = 1, cex = 0.7, ...)
-            if (!is.null(Y)) 
-                points(Y, pch = "+", col = "red", cex = 0.7, 
-                       ...)
+            if (!is.null(X))
+                localPoints(X, pch = 1, col = 1, cex = 0.7, ...)
+            if (!is.null(Y))
+                localPoints(Y, pch = "+", col = "red", cex = 0.7, ...)
         }
         if (type == "text") {
-            if (!is.null(X)) 
-                text(X, labels = rownames(X), col = 1, cex = 0.7, 
-                     ...)
-            if (!is.null(Y)) 
-                text(Y, labels = rownames(Y), col = "red", cex = 0.7, 
-                     ...)
+            if (!is.null(X))
+                localText(X, labels = rownames(X), col = 1, cex = 0.7, ...)
+            if (!is.null(Y))
+                localText(Y, labels = rownames(Y), col = "red", cex = 0.7, ...)
         }
         out <- list(sites = X, species = Y)
     }

Modified: branches/1.17/R/ordiplot3d.R
===================================================================
--- branches/1.17/R/ordiplot3d.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/ordiplot3d.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -16,7 +16,8 @@
                 col = ax.col)
     pl$points3d(c(0, 0), c(0, 0), range(x[, 3]), type = "l", 
                 col = ax.col)
-    if (!missing(envfit) || !is.null(object$CCA)) {
+    if (!missing(envfit) ||
+        (!is.null(object$CCA) && object$CCA$rank > 0)) {
         if (!missing(envfit)) 
             object <- envfit
         bp <- scores(object, dis = "bp", choices = choices, ...)

Modified: branches/1.17/R/ordiresids.R
===================================================================
--- branches/1.17/R/ordiresids.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/ordiresids.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -4,7 +4,7 @@
 {
     require(lattice) || stop("requires package lattice")
     kind <- match.arg(kind)
-    if (!inherits(x, "cca") || is.null(x$CCA))
+    if (!inherits(x, "cca") || is.null(x$CCA) || x$CCA$rank == 0)
         stop("function is only available for constrained ordination")
     fit <- fitted(x, type = residuals)
     res <- residuals(x, type = residuals)

Modified: branches/1.17/R/ordirgl.R
===================================================================
--- branches/1.17/R/ordirgl.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/ordirgl.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -25,7 +25,8 @@
               adj = 0.5)
     rgl.texts(0, 0, 1.1 * max(x[, 3]), colnames(x)[3], col = ax.col, 
               adj = 0.5)
-    if (!missing(envfit) || !is.null(object$CCA)) {
+    if (!missing(envfit) ||
+        (!is.null(object$CCA) && object$CCA$rank > 0)) {
         if (!missing(envfit)) 
             object <- envfit
         bp <- scores(object, dis = "bp", choices = choices)

Modified: branches/1.17/R/ordispider.R
===================================================================
--- branches/1.17/R/ordispider.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/ordispider.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -29,8 +29,10 @@
     inds <- names(table(groups))
     if (label) 
     cntrs <- names <- NULL
+    ## 'kk' removes NA scores
+    kk <- complete.cases(pts)
     for (is in inds) {
-        gr <- out[groups == is]
+        gr <- out[groups == is & kk]
         if (length(gr) > 1) {
             X <- pts[gr, ]
             W <- w[gr]

Modified: branches/1.17/R/ordixyplot.R
===================================================================
--- branches/1.17/R/ordixyplot.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/ordixyplot.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -12,7 +12,8 @@
       v <- colnames(p)
       formula <- as.formula(paste(v[2], "~", v[1]))
     }
-  if ("biplot" %in% type && (!is.null(x$CCA) || !missing(envfit))) {
+  if ("biplot" %in% type && ((!is.null(x$CCA) && x$CCA$rank > 0) ||
+                             !missing(envfit))) {
     if (missing(envfit))
       envfit <- NULL
     env <- ordilattice.getEnvfit(formula, x, envfit, choices, ...)

Modified: branches/1.17/R/predict.cca.R
===================================================================
--- branches/1.17/R/predict.cca.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/predict.cca.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -7,6 +7,8 @@
     if (model == "CCA" && is.null(object$CCA)) 
         model <- "CA"
     take <- object[[model]]$rank
+    if (take == 0)
+        stop("model ", dQuote(model), " has rank 0")
     if (rank != "full") 
         take <- min(take, rank)
     rs <- object$rowsum

Modified: branches/1.17/R/predict.rda.R
===================================================================
--- branches/1.17/R/predict.rda.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/predict.rda.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -7,6 +7,8 @@
     if (model == "CCA" && is.null(object$CCA)) 
         model <- "CA"
     take <- object[[model]]$rank
+    if (take == 0)
+        stop("model ", dQuote(model), " has rank 0")
     if (rank != "full") 
         take <- min(take, rank)
     if (is.null(object$CCA)) 

Modified: branches/1.17/R/screeplot.cca.R
===================================================================
--- branches/1.17/R/screeplot.cca.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/screeplot.cca.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -1,11 +1,11 @@
 `screeplot.cca` <-
     function(x, bstick = FALSE, type = c("barplot", "lines"),
-             npcs = min(10, if(is.null(x$CCA)) x$CA$rank else x$CCA$rank),
+             npcs = min(10, if(is.null(x$CCA) || x$CCA$rank == 0) x$CA$rank else x$CCA$rank),
              ptype = "o", bst.col = "red", bst.lty = "solid",
              xlab = "Component", ylab = "Inertia",
              main = deparse(substitute(x)), legend = bstick, ...)
 {
-    if(is.null(x$CCA))
+    if(is.null(x$CCA) || x$CCA$rank == 0)
         eig.vals <- x$CA$eig
     else
         eig.vals <- x$CCA$eig
@@ -14,7 +14,7 @@
         npcs <- ncomps
     comps <- seq(len=npcs)
     type <- match.arg(type)
-    if (bstick && !is.null(x$CCA)) {
+    if (bstick && !is.null(x$CCA) && x$CCA$rank > 0) {
         warning("'bstick' unavailable for constrained ordination")
         bstick <- FALSE
     }

Modified: branches/1.17/R/swan.R
===================================================================
--- branches/1.17/R/swan.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/swan.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -1,10 +1,13 @@
 swan <-
-function (x)
+function (x, maxit = Inf)
 {
     zeros <- -Inf
-    while(zeros != (zeros <- sum(x == 0)) && any(x == 0)) {
+    iter <- 0
+    while(zeros != (zeros <- sum(x == 0)) && any(x == 0) &&
+          iter < maxit) {
         x[x > 0] <- x[x > 0] - min(x[x > 0]) + 1
         x[x == 0] <- beals(x)[x == 0]
+        iter <- iter + 1
     }
     x
 }

Modified: branches/1.17/R/zzz.R
===================================================================
--- branches/1.17/R/zzz.R	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/R/zzz.R	2011-08-07 17:32:53 UTC (rev 1697)
@@ -1,6 +1,6 @@
-.First.lib <- function(lib, pkg)  {
-    library.dynam("vegan", pkg, lib)
+.onAttach <- function(lib, pkg)  {
     packageStartupMessage("This is vegan ",
-                          utils::packageDescription("vegan", field="Version"),
+                          utils::packageDescription("vegan",
+                                                    field="Version"),
                           appendLF = TRUE)
 }

Modified: branches/1.17/inst/ChangeLog
===================================================================
--- branches/1.17/inst/ChangeLog	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/inst/ChangeLog	2011-08-07 17:32:53 UTC (rev 1697)
@@ -2,8 +2,37 @@
 
 VEGAN RELEASE VERSIONS at http://cran.r-project.org/
 
-Version 1.17-11 (opened April 29, 2011)
+Version 1.17-12 (opened August 7, 2011)
 
+	* Most minor changes and fixes since the release of 1.17-11 (rev
+	1634). Basically everything except 'permute' dependence and
+	monoMDS. Also adds the minimal NAMESPACE file of 1695 (without S3
+	method registration).
+	* partially merged r1696: superfluous aliases in deviance.cca.Rd
+	and predict.cca.Rd, scoping in anova.ccabyterm.R.
+	* merged 1695: minimal NAMESPACE and zzz.R.
+	* merged 1690: make.cepnames upgrade.
+	* merged 1689: NA in orditorp.
+	* merged 1688: duplicated aliases in RsquareAdj.Rd and
+	varpart.Rd. 
+	* merged 1687: ordilabel gained 'select'.
+	* merged 1686: better handling of graphical args in ordiplot.
+	* merged 1685: zero CCA component in anova.ccanull, calibrate.cca,
+	deviance.cca, deviance.rda, ordiplot3d, ordiresids, ordirgl,
+	ordixypplot. 
+	* merged 1684: zero CCA component in bstick.cca, goodness.cca,
+	predict.cca, predict.rda, screeplot.cca.
+	* merged 1683: zero CCA component in anova.cca.
+	* merged 1682: swan upgrade.
+	* merged 1681: split ordiarrows/segments/grid docs.
+	* merged 1680: NA in metaMDSrotate.
+	* merged 1679: NA in ordiellipse/hull/spider.
+	* merged 1678: rename 'index' to 'method' in betadiver.
+	* merged 1652: embeddable capscale (fix 1613).
+	* rev 1636: speed-up of adonis
+	
+Version 1.17-11 (released June 14, 2011)
+
 	* merged r1629,30: added anova.prc().
 	
 	* merged r1625,6: Ref to our MEE paper in anova.cca.Rd.

Modified: branches/1.17/man/RsquareAdj.Rd
===================================================================
--- branches/1.17/man/RsquareAdj.Rd	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/man/RsquareAdj.Rd	2011-08-07 17:32:53 UTC (rev 1697)
@@ -7,7 +7,6 @@
 \alias{RsquareAdj.glm}
 
 \Rdversion{1.1}
-\alias{RsquareAdj}
 
 \title{
 Adjusted R-square

Modified: branches/1.17/man/beals.Rd
===================================================================
--- branches/1.17/man/beals.Rd	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/man/beals.Rd	2011-08-07 17:32:53 UTC (rev 1697)
@@ -14,7 +14,7 @@
 }
 \usage{
 beals(x, species = NA, reference = x, type = 0, include = TRUE)
-swan(x)
+swan(x, maxit = Inf)
 }
 \arguments{
   \item{x}{Community data frame or matrix. }
@@ -29,8 +29,14 @@
   included when computing the mean of the conditioned probabilities. The
   original Beals (1984) definition is equivalent to \code{include=TRUE},
   while the formulation of \enc{Münzbergová}{Munzbergova} and Herben is
-  equal to \code{include=FALSE}. }  
+  equal to \code{include=FALSE}.}
+
+  \item{maxit}{Maximum number of iterations. The default \code{Inf}
+    means that iterations are continued until there are no zeros or
+    the number of zeros does not change. Probably only 
+    \code{maxit = 1} makes sense in addition to the default.}  
 }
+
 \details{
 
   Beals smoothing is the estimated probability \eqn{p_{ij}}{p[ij]} that

Modified: branches/1.17/man/betadiver.Rd
===================================================================
--- branches/1.17/man/betadiver.Rd	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/man/betadiver.Rd	2011-08-07 17:32:53 UTC (rev 1697)
@@ -13,7 +13,7 @@
 }
 
 \usage{
-betadiver(x, index = NA, order = FALSE, help = FALSE, ...)
+betadiver(x, method = NA, order = FALSE, help = FALSE, ...)
 \method{plot}{betadiver}(x, ...)
 \method{scores}{betadiver}(x, triangular = TRUE, ...)
 }
@@ -21,7 +21,7 @@
 \arguments{
   \item{x}{Community data matrix, or the \code{betadiver} result for
   \code{plot} and \code{scores} functions. }
-  \item{index}{The index of beta diversity as defined in Koleff et al.
+  \item{method}{The index of beta diversity as defined in Koleff et al.
   (2003), Table 1. You can use either the subscript of \eqn{\beta} or
   the number of the index. See argument \code{help} below. }
   \item{order}{Order sites by increasing number of species. This will
@@ -67,7 +67,7 @@
   alternatives is much lower than 24 formally provided. The formulations
   used in functions differ occasionally from those in Koleff et
   al. (2003), but they are still mathematically equivalent. With
-  \code{index = NA}, no index is calculated, but instead an object of
+  \code{method = NA}, no index is calculated, but instead an object of
   class \code{betadiver} is returned. This is a list of elements
   \code{a}, \code{b} and \code{c}. Function \code{plot} can be used to
   display the proportions of these elements in triangular plot as
@@ -77,9 +77,9 @@
   object. 
 }
 
-\value{ With \code{index = NA}, the function returns an object of
+\value{ With \code{method = NA}, the function returns an object of
   class \code{"betadisper"} with elements \code{a}, \code{b}, and
-  \code{c}. If \code{index} is specified, the function returns a
+  \code{c}. If \code{method} is specified, the function returns a
   \code{"dist"} object which can be used in any function analysing
   dissimilarities. For beta diversity, particularly useful functions
   are \code{\link{betadisper}} to study the betadiversity in groups,
@@ -92,6 +92,11 @@
   are two such similarity indices.
 }
 
+\note{The argument \code{method} was called \code{index} in older
+  versions of the function (upto \pkg{vegan} version
+  1.17-11). Argument \code{index} is deprecated, but still recognized
+  with a warning. }
+
 \references{
 Koleff, P., Gaston, K.J. and Lennon, J.J. (2003) Measuring beta
 diversity for presence-absence data. \emph{Journal of Animal Ecology}

Modified: branches/1.17/man/deviance.cca.Rd
===================================================================
--- branches/1.17/man/deviance.cca.Rd	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/man/deviance.cca.Rd	2011-08-07 17:32:53 UTC (rev 1697)
@@ -2,7 +2,6 @@
 \name{deviance.cca}
 \alias{deviance.cca}
 \alias{deviance.rda}
-\alias{deviance.capscale}
 \alias{extractAIC.cca}
 \title{ Statistics Resembling Deviance and AIC for Constrained Ordination}
 \description{

Modified: branches/1.17/man/make.cepnames.Rd
===================================================================
--- branches/1.17/man/make.cepnames.Rd	2011-08-06 16:35:16 UTC (rev 1696)
+++ branches/1.17/man/make.cepnames.Rd	2011-08-07 17:32:53 UTC (rev 1697)
@@ -12,23 +12,35 @@
   \code{\link{make.unique}} which adds numbers to the end of CEP names if needed.
 }
 \usage{
-make.cepnames(names)
+make.cepnames(names, seconditem = FALSE)
 }
 \arguments{
   \item{names}{The names to be formatted into CEP names. }
+  \item{seconditem}{Take always the second item of the original name
+    to the abbreviated name instead of the last original item
+    (default).}
 }
-\details{
-  Cornell Ecology Programs (CEP) used eight-letter abbreviations for
-  species and site names. In species, the names were formed by taking
-  four first letters of the generic name and four first letters of the
-  specific or subspecific epithet. The CEP names were originally used,
-  because old \code{FORTRAN IV} did not have \code{CHARACTER} data type,
-  but text  had to be stored in numerical variables, which in
-  popular computers could hold four characters. In modern times,
-  there is no reason for this limitation, but ecologists are used to
-  these names, and they may be practical to avoid congestion in
-  ordination plots. 
+
+\details{ Cornell Ecology Programs (CEP) used eight-letter
+  abbreviations for species and site names. In species, the names were
+  formed by taking four first letters of the generic name and four
+  first letters of the specific or subspecific epithet. The current
+  function first makes valid \R names using \code{\link{make.names}},
+  and then splits these into elemets. The CEP name is made by taking
+  the four first letters of the first element, and four first letters
+  of the last (default) or the second element (with \code{seconditem =
+  TRUE}). If there was only one name element, it is
+  \code{\link{abbreviate}}d to eight letters. Finally, the names are
+  made unique which may add numbers to duplicated names.
+  
+  The CEP names were originally used, because old \code{FORTRAN IV}
+  did not have \code{CHARACTER} data type, but text had to be stored
+  in numerical variables, which in popular computers could hold four
+  characters. In modern times, there is no reason for this limitation,
+  but ecologists are used to these names, and they may be practical to
+  avoid congestion in ordination plots.  
 }
+
 \value{
   Function returns CEP names.
 }

Copied: branches/1.17/man/ordiarrows.Rd (from rev 1681, pkg/vegan/man/ordiarrows.Rd)
===================================================================
--- branches/1.17/man/ordiarrows.Rd	                        (rev 0)
+++ branches/1.17/man/ordiarrows.Rd	2011-08-07 17:32:53 UTC (rev 1697)
@@ -0,0 +1,90 @@
+\name{ordiarrows}
+\alias{ordiarrows}
+\alias{ordisegments}
+\alias{ordigrid}
+
+\title{Add Arrows and Line Segments to Ordination Diagrams}
+
+\description{ Functions to add arrows, line segments, regular grids of
+  points. The ordination diagrams can be produced by \code{vegan}
+  \code{\link{plot.cca}}, \code{\link{plot.decorana}} or
+  \code{\link{ordiplot}}.  }
+
+\usage{
+ordiarrows(ord, groups, levels, replicates, display = "sites",
+         show.groups, startmark, label = FALSE, ...)
+ordisegments(ord, groups, levels, replicates, display = "sites",
+         show.groups, label = FALSE, ...)
+ordigrid(ord, levels, replicates, display = "sites",  lty = c(1,1), 
+         col = c(1,1), lwd = c(1,1), ...)
+}
+
+\arguments{
+  \item{ord}{An ordination object or an \code{\link{ordiplot}} object. }
+  \item{groups}{Factor giving the groups for which the graphical item is
+    drawn. }
+  \item{levels, replicates}{Alternatively, regular
+    groups can be defined with arguments \code{levels} and
+    \code{replicates}, where \code{levels} gives the number of groups,
+    and \code{replicates} the number of successive items at the same
+    group.}
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/vegan -r 1697


More information about the Vegan-commits mailing list