From noreply at r-forge.r-project.org Wed Sep 9 10:19:06 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 9 Sep 2015 10:19:06 +0200 (CEST) Subject: [Vegan-commits] r2959 - pkg/vegan/R Message-ID: <20150909081906.D989518673F@r-forge.r-project.org> Author: jarioksa Date: 2015-09-09 10:19:06 +0200 (Wed, 09 Sep 2015) New Revision: 2959 Modified: pkg/vegan/R/alias.cca.R Log: Merge branch 'cran-2.3' into r-forge-svn-local Modified: pkg/vegan/R/alias.cca.R =================================================================== --- pkg/vegan/R/alias.cca.R 2015-08-28 08:24:02 UTC (rev 2958) +++ pkg/vegan/R/alias.cca.R 2015-09-09 08:19:06 UTC (rev 2959) @@ -1,8 +1,10 @@ `alias.cca` <- function (object, names.only = FALSE, ...) { + if (is.null(object$CCA)) + stop("no constrained component, 'alias' cannot be applied") if (is.null(object$CCA$alias)) - stop("no constrained component, 'alias' cannot be applied") + stop("no aliased terms") if (names.only) return(object$CCA$alias) CompPatt <- function(x, ...) { From noreply at r-forge.r-project.org Tue Sep 15 09:23:31 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 15 Sep 2015 09:23:31 +0200 (CEST) Subject: [Vegan-commits] r2960 - in pkg/vegan: R man Message-ID: <20150915072331.226B9185C2C@r-forge.r-project.org> Author: jarioksa Date: 2015-09-15 09:23:30 +0200 (Tue, 15 Sep 2015) New Revision: 2960 Added: pkg/vegan/R/scalingUtils.R Modified: pkg/vegan/R/biplot.rda.R pkg/vegan/R/plot.cca.R pkg/vegan/R/plot.prc.R pkg/vegan/R/points.cca.R pkg/vegan/R/predict.cca.R pkg/vegan/R/predict.rda.R pkg/vegan/R/scores.cca.R pkg/vegan/R/scores.rda.R pkg/vegan/R/summary.cca.R pkg/vegan/R/summary.prc.R pkg/vegan/R/text.cca.R pkg/vegan/R/tolerance.cca.R pkg/vegan/man/biplot.rda.Rd pkg/vegan/man/plot.cca.Rd pkg/vegan/man/prc.Rd pkg/vegan/man/predict.cca.Rd pkg/vegan/man/tolerance.Rd Log: Merge branch 'cran-2.3' into r-forge-svn-local Modified: pkg/vegan/R/biplot.rda.R =================================================================== --- pkg/vegan/R/biplot.rda.R 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/R/biplot.rda.R 2015-09-15 07:23:30 UTC (rev 2960) @@ -12,9 +12,10 @@ NextMethod("biplot", x, ...) } -`biplot.rda` <- function(x, choices = c(1, 2), scaling = 2, - display = c("sites", "species"), - type, xlim, ylim, col = c(1,2), const, ...) { +`biplot.rda` <- function(x, choices = c(1, 2), scaling = "species", + display = c("sites", "species"), + type, xlim, ylim, col = c(1,2), const, + correlation = FALSE, ...) { if(!inherits(x, "rda")) stop("'biplot.rda' is only for objects of class 'rda'") if(!is.null(x$CCA)) Modified: pkg/vegan/R/plot.cca.R =================================================================== --- pkg/vegan/R/plot.cca.R 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/R/plot.cca.R 2015-09-15 07:23:30 UTC (rev 2960) @@ -1,9 +1,9 @@ -`plot.cca` <- - function (x, choices = c(1, 2), display = c("sp", "wa", "cn"), - scaling = 2, type, xlim, ylim, const, ...) -{ +`plot.cca` <- function (x, choices = c(1, 2), display = c("sp", "wa", "cn"), + scaling = "species", type, xlim, ylim, const, + correlation = FALSE, hill = FALSE, ...) { TYPES <- c("text", "points", "none") - g <- scores(x, choices, display, scaling, const) + g <- scores(x, choices, display, scaling, const, correlation = correlation, + hill = hill) if (length(g) == 0 || all(is.na(g))) stop("nothing to plot: requested scores do not exist") if (!is.list(g)) Modified: pkg/vegan/R/plot.prc.R =================================================================== --- pkg/vegan/R/plot.prc.R 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/R/plot.prc.R 2015-09-15 07:23:30 UTC (rev 2960) @@ -1,11 +1,12 @@ `plot.prc` <- - function (x, species = TRUE, select, scaling = 3, axis = 1, type = "l", - xlab, ylab, ylim, lty = 1:5, col = 1:6, pch, legpos, cex = 0.8, - ...) + function (x, species = TRUE, select, scaling = "symmetric", axis = 1, + correlation = FALSE, type = "l", xlab, ylab, ylim, lty = 1:5, + col = 1:6, pch, legpos, cex = 0.8, ...) { ## save level names before getting the summary levs <- x$terminfo$xlev[[2]] - x <- summary(x, scaling = scaling, axis = axis) + x <- summary(x, scaling = scaling, axis = axis, + correlation = correlation) oldpar <- par(no.readonly = TRUE) on.exit(par(oldpar)) b <- t(coef(x)) Modified: pkg/vegan/R/points.cca.R =================================================================== --- pkg/vegan/R/points.cca.R 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/R/points.cca.R 2015-09-15 07:23:30 UTC (rev 2960) @@ -1,19 +1,20 @@ `points.cca` <- - function (x, display = "sites", choices = c(1, 2), scaling = 2, - arrow.mul, head.arrow = 0.05, select, const, axis.bp = TRUE, ...) + function (x, display = "sites", choices = c(1, 2), scaling = "species", + arrow.mul, head.arrow = 0.05, select, const, axis.bp = TRUE, + correlation = FALSE, hill = FALSE, ...) { formals(arrows) <- c(formals(arrows), alist(... = )) if (length(display) > 1) stop("only one 'display' item can be added in one command") pts <- scores(x, choices = choices, display = display, scaling = scaling, - const) + const, correlation = correlation, hill = hill) if (!missing(select)) pts <- .checkSelect(select, pts) if (display == "cn") { cnam <- rownames(pts) points(pts, ...) pts <- scores(x, choices = choices, display = "bp", scaling = scaling, - const) + const, correlation = correlation, hill = hill) bnam <- rownames(pts) pts <- pts[!(bnam %in% cnam), , drop = FALSE] if (nrow(pts) == 0) Modified: pkg/vegan/R/predict.cca.R =================================================================== --- pkg/vegan/R/predict.cca.R 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/R/predict.cca.R 2015-09-15 07:23:30 UTC (rev 2960) @@ -1,6 +1,7 @@ `predict.cca` <- function (object, newdata, type = c("response", "wa", "sp", "lc", "working"), - rank = "full", model = c("CCA", "CA"), scaling = FALSE, ...) + rank = "full", model = c("CCA", "CA"), scaling = FALSE, + hill = FALSE, ...) { type <- match.arg(type) model <- match.arg(model) @@ -20,6 +21,12 @@ if (is.null(w)) w <- u slam <- diag(sqrt(object[[model]]$eig[1:take]), nrow = take) + ## process sclaing arg, this will ignore hill if scaling = FALSE or a numeric. + ## scaling also used later so needs to be a numeric (or something + ## coercible to one (FALSE) + if (is.character(scaling)) { + scaling <- scalingType(scaling = scaling, hill = hill) + } if (type %in% c("response", "working")) { Xbar <- 0 if (!missing(newdata)) { Modified: pkg/vegan/R/predict.rda.R =================================================================== --- pkg/vegan/R/predict.rda.R 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/R/predict.rda.R 2015-09-15 07:23:30 UTC (rev 2960) @@ -1,6 +1,7 @@ `predict.rda` <- function (object, newdata, type = c("response", "wa", "sp", "lc", "working"), - rank = "full", model = c("CCA", "CA"), scaling = FALSE, ...) + rank = "full", model = c("CCA", "CA"), scaling = FALSE, + correlation = FALSE, ...) { type <- match.arg(type) model <- match.arg(model) @@ -24,6 +25,12 @@ if (is.null(w)) w <- u slam <- diag(sqrt(object[[model]]$eig[1:take] * nr), nrow = take) + ## process sclaing arg, this will ignore hill if scaling = FALSE or a numeric. + ## scaling also used later so needs to be a numeric (or something + ## coercible to one (FALSE) + if (is.character(scaling)) { + scaling <- scalingType(scaling = scaling, correlation = correlation) + } if (type %in% c("response", "working")) { if (!missing(newdata)) { u <- predict(object, type = if(model == "CCA") "lc" else "wa", Added: pkg/vegan/R/scalingUtils.R =================================================================== --- pkg/vegan/R/scalingUtils.R (rev 0) +++ pkg/vegan/R/scalingUtils.R 2015-09-15 07:23:30 UTC (rev 2960) @@ -0,0 +1,17 @@ +##' @title Utility for handling user friendly scaling --- None exported +##' +##' @description Convert user-friendly descriptions of scalings to numeric codes used by \code{scores} to date. +##' +##' @param scaling character; which type of scaling is required? +##' @param correlation logical; should correlation-like scores be returned? +##' @param hill logical; should Hill's scaling scores be returned? +`scalingType` <- function(scaling = c("none", "sites", "species", "symmetric"), + correlation = FALSE, hill = FALSE) { + tab <- c("none", "sites", "species", "symmetric") + scaling <- match.arg(scaling) + scl <- match(scaling, tab) - 1 # -1 as none == scaling 0 + if (scl > 0 && (correlation || hill)) { + scl <- -scl + } + scl # return +} Modified: pkg/vegan/R/scores.cca.R =================================================================== --- pkg/vegan/R/scores.cca.R 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/R/scores.cca.R 2015-09-15 07:23:30 UTC (rev 2960) @@ -1,6 +1,6 @@ `scores.cca` <- - function (x, choices = c(1, 2), display = c("sp", "wa", "cn"), - scaling = 2, ...) + function (x, choices = c(1, 2), display = c("sp", "wa", "cn"), + scaling = "species", hill = FALSE, ...) { if(inherits(x, "pcaiv")) { warning("looks like ade4::cca object: you better use ade4 functions") @@ -10,10 +10,10 @@ ## "exclude" if (!is.null(x$na.action) && inherits(x$na.action, "exclude")) x <- ordiNApredict(x$na.action, x) - tabula <- c("species", "sites", "constraints", "biplot", + tabula <- c("species", "sites", "constraints", "biplot", "centroids") names(tabula) <- c("sp", "wa", "lc", "bp", "cn") - if (is.null(x$CCA)) + if (is.null(x$CCA)) tabula <- tabula[1:2] display <- match.arg(display, c("sites", "species", "wa", "lc", "bp", "cn"), @@ -26,6 +26,10 @@ slam <- sqrt(c(x$CCA$eig, x$CA$eig)[choices]) rnk <- x$CCA$rank sol <- list() + ## check scaling for character & process it if so + if (is.character(scaling)) { + scaling <- scalingType(scaling = scaling, hill = hill) + } if ("species" %in% take) { v <- cbind(x$CCA$v, x$CA$v)[, choices, drop = FALSE] if (scaling) { @@ -64,18 +68,18 @@ } if ("biplot" %in% take && !is.null(x$CCA$biplot)) { b <- matrix(0, nrow(x$CCA$biplot), length(choices)) - b[, choices <= rnk] <- x$CCA$biplot[, choices[choices <= + b[, choices <= rnk] <- x$CCA$biplot[, choices[choices <= rnk]] colnames(b) <- c(colnames(x$CCA$u), colnames(x$CA$u))[choices] rownames(b) <- rownames(x$CCA$biplot) sol$biplot <- b } if ("centroids" %in% take) { - if (is.null(x$CCA$centroids)) + if (is.null(x$CCA$centroids)) sol$centroids <- NA else { cn <- matrix(0, nrow(x$CCA$centroids), length(choices)) - cn[, choices <= rnk] <- x$CCA$centroids[, choices[choices <= + cn[, choices <= rnk] <- x$CCA$centroids[, choices[choices <= rnk]] colnames(cn) <- c(colnames(x$CCA$u), colnames(x$CA$u))[choices] rownames(cn) <- rownames(x$CCA$centroids) @@ -93,14 +97,14 @@ ## Take care that scores have names if (length(sol)) { for (i in seq_along(sol)) { - if (is.matrix(sol[[i]])) + if (is.matrix(sol[[i]])) rownames(sol[[i]]) <- - rownames(sol[[i]], do.NULL = FALSE, + rownames(sol[[i]], do.NULL = FALSE, prefix = substr(names(sol)[i], 1, 3)) } } ## Only one type of scores: return a matrix instead of a list - if (length(sol) == 1) + if (length(sol) == 1) sol <- sol[[1]] sol } Modified: pkg/vegan/R/scores.rda.R =================================================================== --- pkg/vegan/R/scores.rda.R 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/R/scores.rda.R 2015-09-15 07:23:30 UTC (rev 2960) @@ -1,6 +1,6 @@ `scores.rda` <- - function (x, choices = c(1, 2), display = c("sp", "wa", "cn"), - scaling = 2, const, ...) + function (x, choices = c(1, 2), display = c("sp", "wa", "cn"), + scaling = "species", const, correlation = FALSE, ...) { ## Check the na.action, and pad the result with NA or WA if class ## "exclude" @@ -39,6 +39,10 @@ } rnk <- x$CCA$rank sol <- list() + ## check scaling for character & process it if so + if (is.character(scaling)) { + scaling <- scalingType(scaling = scaling, correlation = correlation) + } if ("species" %in% take) { v <- cbind(x$CCA$v, x$CA$v)[, choices, drop=FALSE] if (scaling) { Modified: pkg/vegan/R/summary.cca.R =================================================================== --- pkg/vegan/R/summary.cca.R 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/R/summary.cca.R 2015-09-15 07:23:30 UTC (rev 2960) @@ -1,7 +1,7 @@ -`summary.cca` <- - function (object, scaling = 2, axes = 6, display=c("sp","wa","lc","bp","cn"), - digits = max(3, getOption("digits") - 3), ...) -{ +`summary.cca` <- function (object, scaling = "species", axes = 6, + display=c("sp","wa","lc","bp","cn"), + digits = max(3, getOption("digits") - 3), + correlation = FALSE, hill = FALSE, ...) { if (inherits(object, "pcaiv")) { warning("this is an ade4 object which vegan cannot handle") axes <- min(axes, object$nf) @@ -9,8 +9,12 @@ } axes <- min(axes, sum(object$CCA$rank, object$CA$rank)) summ <- list() + ## scaling is stored in return object so must be in numeric format + scaling <- scalingType(scaling = scaling, correlation = correlation, + hill = hill) if (axes && length(display) && (!is.na(display) && !is.null(display))) - summ <- scores(object, scaling = scaling, choices = 1:axes, display = display, ...) + summ <- scores(object, scaling = scaling, choices = 1:axes, display = display, + ...) ## scores() drops list to a matrix if there is only one item: workaround below. if (!is.list(summ) && length(display) == 1) { nms <- c("species", "sites", "constraints", "biplot", "centroids") Modified: pkg/vegan/R/summary.prc.R =================================================================== --- pkg/vegan/R/summary.prc.R 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/R/summary.prc.R 2015-09-15 07:23:30 UTC (rev 2960) @@ -1,8 +1,7 @@ -`summary.prc` <- - function (object, axis = 1, scaling = 3, digits = 4, ...) -{ +`summary.prc` <- function (object, axis = 1, scaling = "symmetric", + digits = 4, correlation = FALSE, ...) { sc = scores(object, scaling = scaling, display = c("sp", "lc"), - choices=axis, ...) + choices = axis, correlation = correlation, ...) ## coef for scaled sites (coef(object) gives for orthonormal) b <- qr.coef(object$CCA$QR, sc$constraints) prnk <- object$pCCA$rank Modified: pkg/vegan/R/text.cca.R =================================================================== --- pkg/vegan/R/text.cca.R 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/R/text.cca.R 2015-09-15 07:23:30 UTC (rev 2960) @@ -1,12 +1,13 @@ `text.cca` <- - function (x, display = "sites", labels, choices = c(1, 2), scaling = 2, - arrow.mul, head.arrow = 0.05, select, const, axis.bp = TRUE, ...) + function (x, display = "sites", labels, choices = c(1, 2), scaling = "species", + arrow.mul, head.arrow = 0.05, select, const, axis.bp = TRUE, + correlation = FALSE, hill = FALSE, ...) { formals(arrows) <- c(formals(arrows), alist(... = )) if (length(display) > 1) stop("only one 'display' item can be added in one command") pts <- scores(x, choices = choices, display = display, scaling = scaling, - const) + const, correlation = correlation, hill = hill) ## store rownames of pts for use later, otherwise if user supplies ## labels, the checks in "cn" branch fail and "bp" branch will ## be entered even if there should be no "bp" plotting @@ -18,7 +19,7 @@ if (display == "cn") { text(pts, labels = rownames(pts), ...) pts <- scores(x, choices = choices, display = "bp", scaling = scaling, - const) + const, correlation = correlation, hill = hill) bnam <- rownames(pts) pts <- pts[!(bnam %in% cnam), , drop = FALSE] if (nrow(pts) == 0) Modified: pkg/vegan/R/tolerance.cca.R =================================================================== --- pkg/vegan/R/tolerance.cca.R 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/R/tolerance.cca.R 2015-09-15 07:23:30 UTC (rev 2960) @@ -10,7 +10,7 @@ ##' @param which character; one of \code{"species"} or \code{"sites"}, ##' indicating whether species tolerances or sample heterogeneities ##' respectively are computed. -##' @param scaling numeric; the ordination scaling to use. +##' @param scaling numeric or character; the ordination scaling to use. ##' @param useN2 logical; should the bias in the tolerances / ##' heterogeneities be reduced via scaling by Hill's N2? ##' @param ... arguments passed to other methods @@ -25,7 +25,8 @@ ##' tolerance.cca <- function(x, choices = 1:2, which = c("species","sites"), - scaling = 2, useN2 = FALSE, ...) { + scaling = "species", useN2 = FALSE, + hill = FALSE, ...) { if(inherits(x, "rda")) stop("tolerances only available for unimodal ordinations") if(missing(which)) @@ -40,8 +41,10 @@ x$rowsum %o% x$colsum) * x$grand.total which <- match.arg(which) siteScrTypes <- if(is.null(x$CCA)){ "sites" } else {"lc"} + ## Sort out scaling; only for (C)CA so no correlation arg + scaling <- scalingType(scaling, hill = hill) scrs <- scores(x, display = c(siteScrTypes,"species"), - choices = choices, scaling = scaling) + choices = choices, scaling = scaling, ...) ## compute N2 if useN2 == TRUE & only if doN2 <- isTRUE(useN2) && ((which == "species" && abs(scaling) == 2) || (which == "sites" && abs(scaling) == 1)) Modified: pkg/vegan/man/biplot.rda.Rd =================================================================== --- pkg/vegan/man/biplot.rda.Rd 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/man/biplot.rda.Rd 2015-09-15 07:23:30 UTC (rev 2960) @@ -6,9 +6,9 @@ Draws a PCA biplot with species scores indicated by biplot arrows } \usage{ -\method{biplot}{rda}(x, choices = c(1, 2), scaling = 2, +\method{biplot}{rda}(x, choices = c(1, 2), scaling = "species", display = c("sites", "species"), type, xlim, ylim, col = c(1,2), - const, ...) + const, correlation = FALSE, ...) } \arguments{ @@ -21,7 +21,19 @@ scaling values in \code{rda}, species scores are divided by standard deviation of each species and multiplied with an equalizing constant. Unscaled raw scores stored in the result can be accessed - with \code{scaling = 0}.} + with \code{scaling = 0}. + + The type of scores can also be specified as one of \code{"none"}, + \code{"sites"}, \code{"species"}, or \code{"symmetric"}, which + correspond to the values \code{0}, \code{1}, \code{2}, and \code{3} + respectively. Argument \code{correlation} can be used in combination + with these character descriptions to get the corresponding negative + value. + } + \item{correlation}{logical; if \code{scaling} is a character + description of the scaling type, \code{correlation} can be used to + select correlation-like scores for PCA. See argument \code{scaling} + for details.} \item{display}{Scores shown. These must some of the alternatives \code{"species"} for species scores, and/or \code{"sites"} for site scores.} @@ -68,9 +80,9 @@ \examples{ data(dune) mod <- rda(dune, scale = TRUE) -biplot(mod, scaling = 3) +biplot(mod, scaling = "symmetric") ## different type for species and site scores -biplot(mod, scaling = 3, type = c("text", "points")) +biplot(mod, scaling = "symmetric", type = c("text", "points")) } \keyword{hplot} Modified: pkg/vegan/man/plot.cca.Rd =================================================================== --- pkg/vegan/man/plot.cca.Rd 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/man/plot.cca.Rd 2015-09-15 07:23:30 UTC (rev 2960) @@ -19,16 +19,22 @@ } \usage{ \method{plot}{cca}(x, choices = c(1, 2), display = c("sp", "wa", "cn"), - scaling = 2, type, xlim, ylim, const, ...) -\method{text}{cca}(x, display = "sites", labels, choices = c(1, 2), scaling = 2, - arrow.mul, head.arrow = 0.05, select, const, axis.bp = TRUE, ...) -\method{points}{cca}(x, display = "sites", choices = c(1, 2), scaling = 2, - arrow.mul, head.arrow = 0.05, select, const, axis.bp = TRUE, ...) -\method{scores}{cca}(x, choices=c(1,2), display=c("sp","wa","cn"), scaling=2, ...) -\method{scores}{rda}(x, choices=c(1,2), display=c("sp","wa","cn"), scaling=2, - const, ...) -\method{summary}{cca}(object, scaling = 2, axes = 6, display = c("sp", "wa", - "lc", "bp", "cn"), digits = max(3, getOption("digits") - 3), ...) + scaling = "species", type, xlim, ylim, const, + correlation = FALSE, hill = FALSE, ...) +\method{text}{cca}(x, display = "sites", labels, choices = c(1, 2), + scaling = "species", arrow.mul, head.arrow = 0.05, select, const, + axis.bp = TRUE, correlation = FALSE, hill = FALSE, ...) +\method{points}{cca}(x, display = "sites", choices = c(1, 2), + scaling = "species", arrow.mul, head.arrow = 0.05, select, const, + axis.bp = TRUE, correlation = FALSE, hill = FALSE, ...) +\method{scores}{cca}(x, choices = c(1,2), display = c("sp","wa","cn"), + scaling = "species", hill = FALSE, ...) +\method{scores}{rda}(x, choices = c(1,2), display = c("sp","wa","cn"), + scaling = "species", const, correlation = FALSE, ...) +\method{summary}{cca}(object, scaling = "species", axes = 6, + display = c("sp", "wa", "lc", "bp", "cn"), + digits = max(3, getOption("digits") - 3), + correlation = FALSE, hill = FALSE, ...) \method{print}{summary.cca}(x, digits = x$digits, head = NA, tail = head, ...) \method{head}{summary.cca}(x, n = 6, tail = 0, ...) \method{tail}{summary.cca}(x, n = 6, head = 0, ...) @@ -37,25 +43,36 @@ \arguments{ \item{x, object}{A \code{cca} result object.} \item{choices}{Axes shown.} - \item{display}{Scores shown. These must include some of the alternatives - \code{species} or \code{sp} for species scores, \code{sites} or - \code{wa} for site scores, \code{lc} for linear constraints or ``LC - scores'', or \code{bp} for biplot arrows or \code{cn} for centroids - of factor constraints instead of an arrow.} - \item{scaling}{Scaling for species and site scores. Either species + \item{display}{Scores shown. These must include some of the + alternatives \code{species} or \code{sp} for species scores, + \code{sites} or \code{wa} for site scores, \code{lc} for linear + constraints or ``LC scores'', or \code{bp} for biplot arrows or + \code{cn} for centroids of factor constraints instead of an arrow.} + \item{scaling}{Scaling for species and site scores. Either species (\code{2}) or site (\code{1}) scores are scaled by eigenvalues, and the other set of scores is left unscaled, or with \code{3} both are scaled symmetrically by square root of eigenvalues. Corresponding negative values can be used in \code{cca} to additionally multiply - results with \eqn{\sqrt(1/(1-\lambda))}. This scaling is know as - Hill scaling (although it has nothing to do - with Hill's rescaling of \code{\link{decorana}}). With corresponding - negative values in\code{rda}, - species scores are divided by standard deviation of each species and - multiplied with an equalizing constant. - Unscaled raw scores stored in the result can be accessed with - \code{scaling = 0}. + results with \eqn{\sqrt(1/(1-\lambda))}. This scaling is know as Hill + scaling (although it has nothing to do with Hill's rescaling of + \code{\link{decorana}}). With corresponding negative values + in\code{rda}, species scores are divided by standard deviation of each + species and multiplied with an equalizing constant. Unscaled raw + scores stored in the result can be accessed with \code{scaling = 0}. + + The type of scores can also be specified as one of \code{"none"}, + \code{"sites"}, \code{"species"}, or \code{"symmetric"}, which + correspond to the values \code{0}, \code{1}, \code{2}, and \code{3} + respectively. Arguments \code{correlation} and \code{hill} in + \code{scores.rda} and \code{scores.cca} respectively can be used in + combination with these character descriptions to get the + corresponding negative value. } + \item{correlation, hill}{logical; if \code{scaling} is a character + description of the scaling type, \code{correlation} or \code{hill} + are used to select the corresponding negative scaling type; either + correlation-like scores or Hill's scaling for PCA/RDA and CA/CCA + respectively. See argument \code{scaling} for details.} \item{type}{Type of plot: partial match to \code{text} for text labels, \code{points} for points, and \code{none} for setting frames only. If omitted, \code{text} is selected for @@ -165,6 +182,14 @@ ## Limited output of 'summary' head(summary(mod), tail=2) ## Read description of scaling in RDA in vegan: -\dontrun{vegandocs("decision")}} +\dontrun{vegandocs("decision")} + +## Scaling can be numeric or more user-friendly names +## e.g. Hill's scaling for (C)CA +scrs <- scores(mod, scaling = "sites", hill = TRUE) +## or correlation-based scores in PCA/RDA +scrs <- scores(rda(dune ~ A1 + Moisture + Management, dune.env), + scaling = "sites", correlation = TRUE) +} \keyword{hplot} \keyword{aplot} Modified: pkg/vegan/man/prc.Rd =================================================================== --- pkg/vegan/man/prc.Rd 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/man/prc.Rd 2015-09-15 07:23:30 UTC (rev 2960) @@ -17,10 +17,11 @@ \usage{ prc(response, treatment, time, ...) -\method{summary}{prc}(object, axis = 1, scaling = 3, digits = 4, ...) -\method{plot}{prc}(x, species = TRUE, select, scaling = 3, axis = 1, type = "l", - xlab, ylab, ylim, lty = 1:5, col = 1:6, pch, legpos, cex = 0.8, - ...) +\method{summary}{prc}(object, axis = 1, scaling = "symmetric", + digits = 4, correlation = FALSE, ...) +\method{plot}{prc}(x, species = TRUE, select, scaling = "symmetric", + axis = 1, correlation = FALSE, type = "l", xlab, ylab, ylim, + lty = 1:5, col = 1:6, pch, legpos, cex = 0.8, ...) } \arguments{ @@ -33,8 +34,20 @@ \item{object, x}{An \code{prc} result object.} \item{axis}{Axis shown (only one axis can be selected).} \item{scaling}{Scaling of species scores, identical to the - \code{scaling} in \code{\link{scores.rda}}.} + \code{scaling} in \code{\link{scores.rda}}. + + The type of scores can also be specified as one of \code{"none"}, + \code{"sites"}, \code{"species"}, or \code{"symmetric"}, which + correspond to the values \code{0}, \code{1}, \code{2}, and \code{3} + respectively. Argument \code{correlation} can be used in combination + with these character descriptions to get the corresponding negative + value. + } \item{digits}{Number of significant digits displayed.} + \item{correlation}{logical; if \code{scaling} is a character + description of the scaling type, \code{correlation} can be used to + select correlation-like scores for PCA. See argument \code{scaling} + for details.} \item{species}{Display species scores.} \item{select}{Vector to select displayed species. This can be a vector of indices or a logical vector which is \code{TRUE} for the selected Modified: pkg/vegan/man/predict.cca.Rd =================================================================== --- pkg/vegan/man/predict.cca.Rd 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/man/predict.cca.Rd 2015-09-15 07:23:30 UTC (rev 2960) @@ -27,7 +27,11 @@ type = c("response", "working"), ...) \method{residuals}{cca}(object, ...) \method{predict}{cca}(object, newdata, type = c("response", "wa", "sp", "lc", "working"), - rank = "full", model = c("CCA", "CA"), scaling = FALSE, ...) + rank = "full", model = c("CCA", "CA"), scaling = FALSE, + hill = FALSE, ...) +\method{predict}{rda}(object, newdata, type = c("response", "wa", "sp", "lc", "working"), + rank = "full", model = c("CCA", "CA"), scaling = FALSE, + correlation = FALSE, ...) \method{calibrate}{cca}(object, newdata, rank = "full", ...) \method{coef}{cca}(object, ...) \method{predict}{decorana}(object, newdata, type = c("response", "sites", "species"), @@ -70,9 +74,13 @@ \item{rank}{The rank or the number of axes used in the approximation. The default is to use all axes (full rank) of the \code{"model"} or all available four axes in \code{predict.decorana}.} - \item{scaling}{Scaling or predicted scores with the same meaning as - in \code{\link{cca}}, \code{\link{rda}} and - \code{\link{capscale}}.} + \item{scaling}{logical, character, or numeric; Scaling or predicted + scores with the same meaning as in \code{\link{cca}}, + \code{\link{rda}} and \code{\link{capscale}}. See \code{scores.cca} + for further details on acceptable values.} + \item{correlation, hill}{logical; correlation-like scores or Hill's + scaling as appropriate for RDA/\code{\link{capscale}} and CCA + respectively. See \code{\link{scores.cca}} for additional details.} \item{\dots}{Other parameters to the functions.} } \details{ Modified: pkg/vegan/man/tolerance.Rd =================================================================== --- pkg/vegan/man/tolerance.Rd 2015-09-09 08:19:06 UTC (rev 2959) +++ pkg/vegan/man/tolerance.Rd 2015-09-15 07:23:30 UTC (rev 2960) @@ -7,7 +7,7 @@ tolerance(x, \dots) \method{tolerance}{cca}(x, choices = 1:2, which = c("species","sites"), - scaling = 2, useN2 = FALSE, \dots) + scaling = "species", useN2 = FALSE, hill = FALSE, \dots) } \description{ Species tolerances and sample heterogeneities. @@ -29,7 +29,11 @@ \item{which}{character; one of \code{"species"} or \code{"sites"}, indicating whether species tolerances or sample heterogeneities respectively are computed.} - \item{scaling}{numeric; the ordination scaling to use.} + \item{scaling}{character or numeric; the ordination scaling to + use. See \code{\link{scores.cca}} for details.} + \item{hill}{logical; if \code{scaling} is a character, + these control whether Hill's scaling is used for (C)CA + respectively. See \code{\link{scores.cca}} for details.} \item{useN2}{logical; should the bias in the tolerances / heterogeneities be reduced via scaling by Hill's N2?} \item{\dots}{arguments passed to other methods.} From noreply at r-forge.r-project.org Wed Sep 16 13:20:45 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 16 Sep 2015 13:20:45 +0200 (CEST) Subject: [Vegan-commits] r2961 - pkg/vegan/R Message-ID: <20150916112045.C3624186DA3@r-forge.r-project.org> Author: jarioksa Date: 2015-09-16 13:20:43 +0200 (Wed, 16 Sep 2015) New Revision: 2961 Modified: pkg/vegan/R/scalingUtils.R Log: Merge branch 'cran-2.3' into r-forge-svn-local Modified: pkg/vegan/R/scalingUtils.R =================================================================== --- pkg/vegan/R/scalingUtils.R 2015-09-15 07:23:30 UTC (rev 2960) +++ pkg/vegan/R/scalingUtils.R 2015-09-16 11:20:43 UTC (rev 2961) @@ -6,7 +6,12 @@ ##' @param correlation logical; should correlation-like scores be returned? ##' @param hill logical; should Hill's scaling scores be returned? `scalingType` <- function(scaling = c("none", "sites", "species", "symmetric"), - correlation = FALSE, hill = FALSE) { + correlation = FALSE, hill = FALSE) +{ + ## numeric scaling: return as-is + if (is.numeric(scaling)) + return(scaling) + ## non-numeric scaling: change to numeric tab <- c("none", "sites", "species", "symmetric") scaling <- match.arg(scaling) scl <- match(scaling, tab) - 1 # -1 as none == scaling 0 From noreply at r-forge.r-project.org Thu Sep 17 12:03:56 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 17 Sep 2015 12:03:56 +0200 (CEST) Subject: [Vegan-commits] r2962 - in pkg/vegan: . R inst man Message-ID: <20150917100356.B0394185658@r-forge.r-project.org> Author: jarioksa Date: 2015-09-17 12:03:56 +0200 (Thu, 17 Sep 2015) New Revision: 2962 Modified: pkg/vegan/NAMESPACE pkg/vegan/R/anova.cca.R pkg/vegan/R/anova.ccabyterm.R pkg/vegan/R/anova.ccalist.R pkg/vegan/R/permustats.R pkg/vegan/inst/NEWS.Rd pkg/vegan/man/anova.cca.Rd pkg/vegan/man/permustats.Rd Log: Merge branch 'cran-2.3' into r-forge-svn-local Modified: pkg/vegan/NAMESPACE =================================================================== --- pkg/vegan/NAMESPACE 2015-09-16 11:20:43 UTC (rev 2961) +++ pkg/vegan/NAMESPACE 2015-09-17 10:03:56 UTC (rev 2962) @@ -254,6 +254,7 @@ S3method(permustats, permutest.betadisper) S3method(permustats, permutest.cca) S3method(permustats, protest) +S3method(permustats, anova.cca) ## these return an error: no permutation data S3method(permustats, CCorA) S3method(permustats, envfit) Modified: pkg/vegan/R/anova.cca.R =================================================================== --- pkg/vegan/R/anova.cca.R 2015-09-16 11:20:43 UTC (rev 2961) +++ pkg/vegan/R/anova.cca.R 2015-09-17 10:03:56 UTC (rev 2962) @@ -74,6 +74,6 @@ tst$model, " model\n", howHead(control)) mod <- paste("Model:", c(object$call)) structure(table, heading = c(head, mod), Random.seed = seed, - control = control, + control = control, F.perm = tst$F.perm, class = c("anova.cca", "anova", "data.frame")) } Modified: pkg/vegan/R/anova.ccabyterm.R =================================================================== --- pkg/vegan/R/anova.ccabyterm.R 2015-09-16 11:20:43 UTC (rev 2961) +++ pkg/vegan/R/anova.ccabyterm.R 2015-09-17 10:03:56 UTC (rev 2962) @@ -17,9 +17,9 @@ trmlab <- trmlab[trmlab %in% attr(terms(object$terminfo), "term.labels")] ntrm <- length(trmlab) - m0 <- update(object, paste(".~.-", paste(trmlab, collapse="-"))) + m0 <- update(object, paste(".~.-", paste(trmlab, collapse = "-"))) mods <- list(m0) - for(i in seq_along(trmlab)) { + for (i in seq_along(trmlab)) { fla <- paste(". ~ . + ", trmlab[i]) mods[[i+1]] <- update(mods[[i]], fla) } @@ -46,7 +46,8 @@ howHead(attr(permutations, "control"))) mod <- paste("Model:", c(object$call)) attr(out, "heading") <- c(head, mod) - class(out) <- c("anova","data.frame") + attr(out, "F.perm") <- attr(sol, "F.perm") + class(out) <- c("anova.cca", "anova","data.frame") out } @@ -68,7 +69,7 @@ trms <- drop.scope(object) trmlab <- trms[trms %in% attr(terms(object$terminfo), "term.labels")] - if(length(trmlab) == 0) + if (length(trmlab) == 0) stop("the scope was empty: no available marginal terms") ## baseline: all terms big <- permutest(object, permutations, ...) @@ -91,7 +92,7 @@ Fval <- sapply(mods, function(x) x$num) ## Had we an empty model we need to clone the denominator if (length(Fval) == 1) - Fval <- matrix(Fval, nrow=nperm) + Fval <- matrix(Fval, nrow = nperm) Fval <- sweep(-Fval, 1, big$num, "+") Fval <- sweep(Fval, 2, Df, "/") Fval <- sweep(Fval, 1, scale, "/") @@ -115,7 +116,8 @@ howHead(attr(permutations, "control"))) mod <- paste("Model:", c(object$call)) attr(out, "heading") <- c(head, mod) - class(out) <- c("anova", "data.frame") + attr(out, "F.perm") <- Fval + class(out) <- c("anova.cca", "anova", "data.frame") out } @@ -136,10 +138,10 @@ ## missing values? if (!is.null(object$na.action)) LC <- napredict(structure(object$na.action, - class="exclude"), LC) + class = "exclude"), LC) ## subset? if (!is.null(object$subset)) { - tmp <- matrix(NA, nrow=length(object$subset), + tmp <- matrix(NA, nrow = length(object$subset), ncol = ncol(LC)) tmp[object$subset,] <- LC LC <- tmp @@ -148,6 +150,7 @@ LC <- as.data.frame(LC) fla <- reformulate(names(LC)) Pvals <- rep(NA, length(eig)) + F.perm <- matrix(ncol = length(eig), nrow = nperm) environment(object$terms) <- environment() for (i in seq_along(eig)) { part <- paste("~ . +Condition(", @@ -162,7 +165,8 @@ permutest(update(object, upfla, data = LC), permutations, model = model, parallel = parallel) - Pvals[i] <- (sum(mod$F.perm >= mod$F.0) + 1)/(nperm+1) + Pvals[i] <- (sum(mod$F.perm >= mod$F.0) + 1) / (nperm + 1) + F.perm[ , i] <- mod$F.perm if (Pvals[i] > cutoff) break } @@ -183,6 +187,7 @@ howHead(attr(permutations, "control"))) mod <- paste("Model:", c(object$call)) attr(out, "heading") <- c(head, mod) - class(out) <- c("anova", "data.frame") + attr(out, "F.perm") <- F.perm + class(out) <- c("anova.cca", "anova", "data.frame") out } Modified: pkg/vegan/R/anova.ccalist.R =================================================================== --- pkg/vegan/R/anova.ccalist.R 2015-09-16 11:20:43 UTC (rev 2961) +++ pkg/vegan/R/anova.ccalist.R 2015-09-17 10:03:56 UTC (rev 2962) @@ -27,8 +27,8 @@ ## 4. Terms must be nested trms <- lapply(object, function(z) labels(terms(z))) o <- order(sapply(trms, length)) - for(i in 2:nmodels) - if(!all(trms[[o[i-1]]] %in% trms[[o[i]]])) + for (i in 2:nmodels) + if (!all(trms[[o[i-1]]] %in% trms[[o[i]]])) stop("models must be nested") ## Check permutation matrix @@ -65,7 +65,7 @@ pfvals <- apply(pfvals, 1, diff) ## dropped to vector? if (!is.matrix(pfvals)) - pfvals <- matrix(pfvals, nrow=1, ncol=nperm) + pfvals <- matrix(pfvals, nrow = 1, ncol = nperm) pfvals <- sweep(pfvals, 1, df, "/") pfvals <- sweep(pfvals, 2, pscale, "/") pval <- rowSums(sweep(pfvals, 1, fval - EPS, ">=")) @@ -90,5 +90,7 @@ howHead(attr(permutations, "control"))) topnote <- paste("Model ", format(1L:nmodels), ": ", formulae, sep = "", collapse = "\n") - structure(table, heading=c(head,topnote), class = c("anova", "data.frame")) + structure(table, heading = c(head,topnote), + F.perm = t(pfvals), + class = c("anova.cca", "anova", "data.frame")) } Modified: pkg/vegan/R/permustats.R =================================================================== --- pkg/vegan/R/permustats.R 2015-09-16 11:20:43 UTC (rev 2961) +++ pkg/vegan/R/permustats.R 2015-09-17 10:03:56 UTC (rev 2962) @@ -147,10 +147,10 @@ function(x, ...) { structure(list( - "statistic" = structure(x$statistic, names="R"), + "statistic" = structure(x$statistic, names = "R"), "permutations" = x$perm, "alternative" = "greater"), - class="permustats") + class = "permustats") } `permustats.adonis` <- @@ -162,27 +162,27 @@ "statistic" = structure(tab$F.Model[k], names = rownames(tab)[k]), "permutations" = x$f.perms, "alternative" = "greater"), - class="permustats") + class = "permustats") } `permustats.mantel` <- function(x, ...) { structure(list( - "statistic" = structure(x$statistic, names="r"), + "statistic" = structure(x$statistic, names = "r"), "permutations" = x$perm, "alternative" = "greater"), - class="permustats") + class = "permustats") } `permustats.mrpp` <- function(x, ...) { structure(list( - "statistic" = structure(x$delta, names="delta"), + "statistic" = structure(x$delta, names = "delta"), "permutations" = x$boot.deltas, "alternative" = "less"), - class="permustats") + class = "permustats") } `permustats.oecosimu` <- @@ -192,7 +192,7 @@ "statistic" = x$oecosimu$statistic, "permutations" = t(x$oecosimu$simulated), "alternative" = x$oecosimu$alternative), - class="permustats") + class = "permustats") } `permustats.ordiareatest` <- @@ -212,7 +212,7 @@ "statistic" = structure(x$F.0, names = "F"), "permutations" = x$F.perm, "alternative" = "greater"), - class="permustats") + class = "permustats") } `permustats.protest` <- @@ -222,7 +222,7 @@ "statistic" = structure(x$t0, names = "r"), "permutations" = x$t, "alternative" = "greater"), - class="permustats") + class = "permustats") } ### the following do not return permutation data @@ -268,5 +268,20 @@ structure(list("statistic" = x$statistic, "permutations" = x$perm, "alternative" = alt), - class ="permustats") + class = "permustats") } + +`permustats.anova.cca` <- + function(x, ...) +{ + if (is.null(attr(x, "F.perm"))) + stop("no permutation data available") + F.perm <- attr(x, "F.perm") + k <- !is.na(x$F) + F.0 <- x$F[k] + structure(list( + "statistic" = structure(F.0, names = rownames(x)[k]), + "permutations" = F.perm, + "alternative" = "greater"), + class = "permustats") +} \ No newline at end of file Modified: pkg/vegan/inst/NEWS.Rd =================================================================== --- pkg/vegan/inst/NEWS.Rd 2015-09-16 11:20:43 UTC (rev 2961) +++ pkg/vegan/inst/NEWS.Rd 2015-09-17 10:03:56 UTC (rev 2962) @@ -47,12 +47,30 @@ input data are integers that can be interpreted as counts on individuals and all sampling units have some species. Unchecked bad inputs were the reason for problems reported in - \href{http://stackoverflow.com/questions/30856909/error-while-using-rarecurve-in-r}{Stackoverflow (Error while using rarecurve)}. + \href{http://stackoverflow.com/questions/30856909/error-while-using-rarecurve-in-r}{Stackoverflow}. } + } % bug fixes - } + \subsection{NEW FEATURES AND FUNCTIONS}{ + \itemize{ + + \item Scaling of ordination axes in \code{cca}, \code{rda} and + \code{capscale} can now be expressed with descriptive strings + \code{"none"}, \code{"sites"}, \code{"species"} or + \code{"symmetric"} to tell which kind of scores should be scaled by + eigenvalues. These can be further modified with arguments + \code{hill} in \code{cca} and \code{correlation} in \code{rda}. The + old numeric scaling can still be used. + \item The permutation data can be extracted from \code{anova} + results of constrained ordination (\code{cca}, \code{rda}, + \code{capscale}) and further analysed with \code{permustats} + function. + + } + } % new features and functions + } \section{Changes in version 2.3-0}{ Modified: pkg/vegan/man/anova.cca.Rd =================================================================== --- pkg/vegan/man/anova.cca.Rd 2015-09-16 11:20:43 UTC (rev 2961) +++ pkg/vegan/man/anova.cca.Rd 2015-09-17 10:03:56 UTC (rev 2962) @@ -145,7 +145,10 @@ \value{ The function \code{anova.cca} calls \code{permutest.cca} and fills an - \code{\link{anova}} table. + \code{\link{anova}} table. Additional attributes are + \code{Random.seed} (the random seeds used), + \code{control} (the permutation design, see \link[permute]{how}) and + \code{F.perm} (the permuted test statistics). } \note{ Modified: pkg/vegan/man/permustats.Rd =================================================================== --- pkg/vegan/man/permustats.Rd 2015-09-16 11:20:43 UTC (rev 2961) +++ pkg/vegan/man/permustats.Rd 2015-09-17 10:03:56 UTC (rev 2962) @@ -1,3 +1,4 @@ +\encoding{UTF-8} \name{permustats} \alias{permustats} \alias{permustats.adonis} @@ -2,2 +3,3 @@ \alias{permustats.anosim} +\alias{permustats.anova.cca} \alias{permustats.CCorA} @@ -91,13 +93,11 @@ arguments to their underlying functions; see their documentation. The \code{permustats} can extract permutation statistics from the - results of \code{\link{adonis}}, \code{\link{anosim}}, - \code{\link{mantel}}, \code{\link{mantel.partial}}, + results of \code{\link{adonis}}, \code{\link{anosim}}, + \code{\link{anova.cca}}, \code{\link{mantel}}, \code{\link{mantel.partial}}, \code{\link{mrpp}}, \code{\link{oecosimu}}, \code{\link{ordiareatest}}, \code{\link{permutest.cca}}, \code{\link{protest}}, and - \code{\link{permutest.betadisper}}. NB, there is no \code{permustats} - method for \code{\link{anova.cca}}, but only for - \code{\link{permutest.cca}}. + \code{\link{permutest.betadisper}}. } @@ -115,7 +115,7 @@ Jari Oksanen with contributions from Gavin L. Simpson (\code{permustats.permutest.betadisper} method and related modifications to \code{summary.permustats} and the \code{print} - method. + method) and Eduard \enc{Sz?cs}{Szoecs} (\code{permustats.anova.cca).} } \seealso{ From noreply at r-forge.r-project.org Thu Sep 17 12:05:29 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 17 Sep 2015 12:05:29 +0200 (CEST) Subject: [Vegan-commits] r2963 - www Message-ID: <20150917100529.68F0A183C0B@r-forge.r-project.org> Author: jarioksa Date: 2015-09-17 12:05:29 +0200 (Thu, 17 Sep 2015) New Revision: 2963 Modified: www/NEWS.html Log: update www NEWS Modified: www/NEWS.html =================================================================== --- www/NEWS.html 2015-09-17 10:03:56 UTC (rev 2962) +++ www/NEWS.html 2015-09-17 10:05:29 UTC (rev 2963) @@ -59,13 +59,36 @@ input data are integers that can be interpreted as counts on individuals and all sampling units have some species. Unchecked bad inputs were the reason for problems reported in -Stackoverflow (Error while using rarecurve). +Stackoverflow.

+ +

NEW FEATURES AND FUNCTIONS

+ + + + + +

Changes in version 2.3-0

From noreply at r-forge.r-project.org Mon Sep 21 08:37:06 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 21 Sep 2015 08:37:06 +0200 (CEST) Subject: [Vegan-commits] r2964 - in pkg/vegan: . R man Message-ID: <20150921063707.01C6E186D34@r-forge.r-project.org> Author: jarioksa Date: 2015-09-21 08:37:06 +0200 (Mon, 21 Sep 2015) New Revision: 2964 Modified: pkg/vegan/DESCRIPTION pkg/vegan/R/predict.cca.R pkg/vegan/R/predict.rda.R pkg/vegan/R/scalingUtils.R pkg/vegan/R/scores.cca.R pkg/vegan/R/scores.rda.R pkg/vegan/man/predict.cca.Rd Log: Merge branch 'cran-2.3' into r-forge-svn-local Modified: pkg/vegan/DESCRIPTION =================================================================== --- pkg/vegan/DESCRIPTION 2015-09-17 10:05:29 UTC (rev 2963) +++ pkg/vegan/DESCRIPTION 2015-09-21 06:37:06 UTC (rev 2964) @@ -1,7 +1,7 @@ Package: vegan Title: Community Ecology Package Version: 2.3-1 -Date: 2015-05-28 +Date: 2015-09-18 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: pkg/vegan/R/predict.cca.R =================================================================== --- pkg/vegan/R/predict.cca.R 2015-09-17 10:05:29 UTC (rev 2963) +++ pkg/vegan/R/predict.cca.R 2015-09-21 06:37:06 UTC (rev 2964) @@ -1,6 +1,6 @@ `predict.cca` <- function (object, newdata, type = c("response", "wa", "sp", "lc", "working"), - rank = "full", model = c("CCA", "CA"), scaling = FALSE, + rank = "full", model = c("CCA", "CA"), scaling = "none", hill = FALSE, ...) { type <- match.arg(type) @@ -21,12 +21,8 @@ if (is.null(w)) w <- u slam <- diag(sqrt(object[[model]]$eig[1:take]), nrow = take) - ## process sclaing arg, this will ignore hill if scaling = FALSE or a numeric. - ## scaling also used later so needs to be a numeric (or something - ## coercible to one (FALSE) - if (is.character(scaling)) { - scaling <- scalingType(scaling = scaling, hill = hill) - } + ## process scaling arg, scaling used later so needs to be a numeric + scaling <- scalingType(scaling = scaling, hill = hill) if (type %in% c("response", "working")) { Xbar <- 0 if (!missing(newdata)) { @@ -63,7 +59,7 @@ u <- u[, 1:take, drop = FALSE] } out <- u - if (scaling) { + if (scaling) { # implicit conversion "none" == 0 == FALSE scal <- list(diag(slam), 1, sqrt(diag(slam)))[[abs(scaling)]] out <- sweep(out, 2, scal, "*") if (scaling < 0) { @@ -94,7 +90,7 @@ w <- sweep(w, 2, diag(slam), "/") } out <- w - if (scaling) { + if (scaling) { # implicit conversion "none" == 0 == FALSE scal <- list(diag(slam), 1, sqrt(diag(slam)))[[abs(scaling)]] out <- sweep(out, 2, scal, "*") if (scaling < 0) { @@ -121,7 +117,7 @@ v <- sweep(v, 2, diag(slam), "/") } out <- v - if (scaling) { + if (scaling) { # implicit conversion "none" == 0 == FALSE scal <- list(1, diag(slam), sqrt(diag(slam)))[[abs(scaling)]] out <- sweep(out, 2, scal, "*") if (scaling < 0) { Modified: pkg/vegan/R/predict.rda.R =================================================================== --- pkg/vegan/R/predict.rda.R 2015-09-17 10:05:29 UTC (rev 2963) +++ pkg/vegan/R/predict.rda.R 2015-09-21 06:37:06 UTC (rev 2964) @@ -1,6 +1,6 @@ `predict.rda` <- function (object, newdata, type = c("response", "wa", "sp", "lc", "working"), - rank = "full", model = c("CCA", "CA"), scaling = FALSE, + rank = "full", model = c("CCA", "CA"), scaling = "none", correlation = FALSE, ...) { type <- match.arg(type) @@ -25,12 +25,8 @@ if (is.null(w)) w <- u slam <- diag(sqrt(object[[model]]$eig[1:take] * nr), nrow = take) - ## process sclaing arg, this will ignore hill if scaling = FALSE or a numeric. - ## scaling also used later so needs to be a numeric (or something - ## coercible to one (FALSE) - if (is.character(scaling)) { - scaling <- scalingType(scaling = scaling, correlation = correlation) - } + ## process scaling arg, scaling used later so needs to be a numeric + scaling <- scalingType(scaling = scaling, correlation = correlation) if (type %in% c("response", "working")) { if (!missing(newdata)) { u <- predict(object, type = if(model == "CCA") "lc" else "wa", @@ -82,7 +78,7 @@ u <- u[, 1:take, drop = FALSE] } out <- u - if (scaling) { + if (scaling) { # implicit coercion 0 == FALSE, other == TRUE tot <- sqrt(object$tot.chi * nr) lam <- list(diag(slam)/tot, 1, sqrt(diag(slam)/tot))[[abs(scaling)]] out <- sqrt(tot) * sweep(out, 2, lam, "*") @@ -110,7 +106,7 @@ w <- sweep(w, 2, diag(slam), "/") } out <- w - if (scaling) { + if (scaling) { # implicit coercion 0 == FALSE, other == TRUE tot <- sqrt(object$tot.chi * nr) lam <- list(diag(slam)/tot, 1, sqrt(diag(slam)/tot))[[abs(scaling)]] out <- sqrt(tot) * sweep(out, 2, lam, "*") @@ -134,7 +130,7 @@ v <- sweep(v, 2, diag(slam), "/") } out <- v - if (scaling) { + if (scaling) { # implicit coercion 0 == FALSE, other == TRUE tot <- sqrt(object$tot.chi * nr) scal <- list(1, diag(slam)/tot, sqrt(diag(slam)/tot))[[abs(scaling)]] out <- sqrt(tot) * sweep(out, 2, scal, "*") Modified: pkg/vegan/R/scalingUtils.R =================================================================== --- pkg/vegan/R/scalingUtils.R 2015-09-17 10:05:29 UTC (rev 2963) +++ pkg/vegan/R/scalingUtils.R 2015-09-21 06:37:06 UTC (rev 2964) @@ -2,21 +2,26 @@ ##' ##' @description Convert user-friendly descriptions of scalings to numeric codes used by \code{scores} to date. ##' -##' @param scaling character; which type of scaling is required? +##' @param scaling character or numeric; which type of scaling is required? Numeric values are returned unaltered ##' @param correlation logical; should correlation-like scores be returned? ##' @param hill logical; should Hill's scaling scores be returned? `scalingType` <- function(scaling = c("none", "sites", "species", "symmetric"), - correlation = FALSE, hill = FALSE) -{ - ## numeric scaling: return as-is - if (is.numeric(scaling)) - return(scaling) - ## non-numeric scaling: change to numeric - tab <- c("none", "sites", "species", "symmetric") - scaling <- match.arg(scaling) - scl <- match(scaling, tab) - 1 # -1 as none == scaling 0 - if (scl > 0 && (correlation || hill)) { - scl <- -scl + correlation = FALSE, hill = FALSE) { + ## Only process scaling further if it is character + if (is.numeric(scaling)) { + return(scaling) # numeric; return early + } else if (is.character(scaling)) { + ## non-numeric scaling: change to correct numeric code + scaling <- match.arg(scaling) # match user choice + ## Keep `tab` as this is the order of numeric codes + ## Allows potential to change the default ordering of formal argument 'scaling' + tab <- c("none", "sites", "species", "symmetric") + scaling <- match(scaling, tab) - 1 # -1 as none == scaling 0 + if (correlation || hill) { + scaling <- -scaling + } + } else { + stop("'scaling' is not 'numeric' nor 'character'.") } - scl # return + scaling # return } Modified: pkg/vegan/R/scores.cca.R =================================================================== --- pkg/vegan/R/scores.cca.R 2015-09-17 10:05:29 UTC (rev 2963) +++ pkg/vegan/R/scores.cca.R 2015-09-21 06:37:06 UTC (rev 2964) @@ -26,10 +26,8 @@ slam <- sqrt(c(x$CCA$eig, x$CA$eig)[choices]) rnk <- x$CCA$rank sol <- list() - ## check scaling for character & process it if so - if (is.character(scaling)) { - scaling <- scalingType(scaling = scaling, hill = hill) - } + ## process scaling; numeric scaling will just be returned as is + scaling <- scalingType(scaling = scaling, hill = hill) if ("species" %in% take) { v <- cbind(x$CCA$v, x$CA$v)[, choices, drop = FALSE] if (scaling) { Modified: pkg/vegan/R/scores.rda.R =================================================================== --- pkg/vegan/R/scores.rda.R 2015-09-17 10:05:29 UTC (rev 2963) +++ pkg/vegan/R/scores.rda.R 2015-09-21 06:37:06 UTC (rev 2964) @@ -39,10 +39,8 @@ } rnk <- x$CCA$rank sol <- list() - ## check scaling for character & process it if so - if (is.character(scaling)) { - scaling <- scalingType(scaling = scaling, correlation = correlation) - } + ## process scaling; numeric scaling will just be returned as is + scaling <- scalingType(scaling = scaling, correlation = correlation) if ("species" %in% take) { v <- cbind(x$CCA$v, x$CA$v)[, choices, drop=FALSE] if (scaling) { Modified: pkg/vegan/man/predict.cca.Rd =================================================================== --- pkg/vegan/man/predict.cca.Rd 2015-09-17 10:05:29 UTC (rev 2963) +++ pkg/vegan/man/predict.cca.Rd 2015-09-21 06:37:06 UTC (rev 2964) @@ -27,10 +27,10 @@ type = c("response", "working"), ...) \method{residuals}{cca}(object, ...) \method{predict}{cca}(object, newdata, type = c("response", "wa", "sp", "lc", "working"), - rank = "full", model = c("CCA", "CA"), scaling = FALSE, + rank = "full", model = c("CCA", "CA"), scaling = "none", hill = FALSE, ...) \method{predict}{rda}(object, newdata, type = c("response", "wa", "sp", "lc", "working"), - rank = "full", model = c("CCA", "CA"), scaling = FALSE, + rank = "full", model = c("CCA", "CA"), scaling = "none", correlation = FALSE, ...) \method{calibrate}{cca}(object, newdata, rank = "full", ...) \method{coef}{cca}(object, ...) From noreply at r-forge.r-project.org Wed Sep 23 15:09:35 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 23 Sep 2015 15:09:35 +0200 (CEST) Subject: [Vegan-commits] r2965 - in pkg/vegan: R data inst man Message-ID: <20150923130935.7785318103A@r-forge.r-project.org> Author: jarioksa Date: 2015-09-23 15:09:34 +0200 (Wed, 23 Sep 2015) New Revision: 2965 Added: pkg/vegan/data/BCI.env.rda Modified: pkg/vegan/R/metaMDS.R pkg/vegan/R/monoMDS.R pkg/vegan/inst/NEWS.Rd pkg/vegan/man/BCI.Rd Log: Merge branch 'cran-2.3' into r-forge-svn-local Modified: pkg/vegan/R/metaMDS.R =================================================================== --- pkg/vegan/R/metaMDS.R 2015-09-21 06:37:06 UTC (rev 2964) +++ pkg/vegan/R/metaMDS.R 2015-09-23 13:09:34 UTC (rev 2965) @@ -16,7 +16,7 @@ ## metaMDS was written for community data which should be all ## positive. Check this here, and set arguments so that they are ## suitable for non-negative data. - if (any(autotransform, noshare > 0, wascores) && any(comm < 0)) { + if (any(autotransform, noshare > 0, wascores) && any(comm < 0, na.rm=TRUE)) { warning("'comm' has negative data: 'autotransform', 'noshare' and 'wascores' set to FALSE") wascores <- FALSE autotransform <- FALSE Modified: pkg/vegan/R/monoMDS.R =================================================================== --- pkg/vegan/R/monoMDS.R 2015-09-21 06:37:06 UTC (rev 2964) +++ pkg/vegan/R/monoMDS.R 2015-09-23 13:09:34 UTC (rev 2965) @@ -10,7 +10,7 @@ && ncol(dist) == nrow(dist) && isTRUE(all.equal(dist[lower.tri(dist)], t(dist)[lower.tri(dist)])))) stop("'dist' must be a distance object (class \"dist\") or a symmetric square matrix") - if (any(dist < -sqrt(.Machine$double.eps))) + if (any(dist < -sqrt(.Machine$double.eps), na.rm = TRUE)) warning("some dissimilarities are negative -- is this intentional?") ## match.arg model <- match.arg(model) Added: pkg/vegan/data/BCI.env.rda =================================================================== --- pkg/vegan/data/BCI.env.rda (rev 0) +++ pkg/vegan/data/BCI.env.rda 2015-09-23 13:09:34 UTC (rev 2965) @@ -0,0 +1,2 @@ +? r?0???b```b`fbb`b2Y??# '?fwr??K?+c``r??????%6?????0-YM-?L-?M$}?8Zf6q?l2q??6??g?h?????x????G??VG??+!??B??B?b??????'??xa`?|4<0?? ?3???4???:???l9?e?9?@?X"??lg??`M?I,?i????\?_d?C +0???A?g???c??$? 3? JX?]^bn*,??`?CC|?\??y~?Po at QjrfAfIbIf~T??g?????z??%0?{j~N~z%?q?$?$????? Author: jarioksa Date: 2015-09-23 15:22:53 +0200 (Wed, 23 Sep 2015) New Revision: 2966 Modified: www/NEWS.html Log: latest NEWS for 2.3-1 to come Modified: www/NEWS.html =================================================================== --- www/NEWS.html 2015-09-23 13:09:34 UTC (rev 2965) +++ www/NEWS.html 2015-09-23 13:22:53 UTC (rev 2966) @@ -54,6 +54,10 @@ long expressions. Reported by Richard Telford.

+
  • metaMDS and monoMDS did not accept missing +values in dissimilarities. +

    +
  • Function rarecurve did not check its input and this could cause confusing error messages. Now function checks that input data are integers that can be interpreted as counts on @@ -84,6 +88,12 @@ capscale) and further analysed with permustats function.

    +
  • +
  • Added environmental data set BCI.env to the Barro +Colorado Island tree data. Most useful variables are the UTM +coordinates of sample plots. Other variables are constant or nearly +constant and of little use in normal analysis. +

  • From noreply at r-forge.r-project.org Thu Sep 24 10:39:46 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 24 Sep 2015 10:39:46 +0200 (CEST) Subject: [Vegan-commits] r2967 - in pkg/vegan: . inst Message-ID: <20150924083946.1C8BE18111F@r-forge.r-project.org> Author: jarioksa Date: 2015-09-24 10:39:45 +0200 (Thu, 24 Sep 2015) New Revision: 2967 Modified: pkg/vegan/DESCRIPTION pkg/vegan/inst/NEWS.Rd Log: Merge branch 'cran-2.3' into r-forge-svn-local Modified: pkg/vegan/DESCRIPTION =================================================================== --- pkg/vegan/DESCRIPTION 2015-09-23 13:22:53 UTC (rev 2966) +++ pkg/vegan/DESCRIPTION 2015-09-24 08:39:45 UTC (rev 2967) @@ -1,7 +1,7 @@ Package: vegan Title: Community Ecology Package Version: 2.3-1 -Date: 2015-09-18 +Date: 2015-09-24 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: pkg/vegan/inst/NEWS.Rd =================================================================== --- pkg/vegan/inst/NEWS.Rd 2015-09-23 13:22:53 UTC (rev 2966) +++ pkg/vegan/inst/NEWS.Rd 2015-09-24 08:39:45 UTC (rev 2967) @@ -42,8 +42,8 @@ addition, the deparsed expression for \code{comm} is now robust to long expressions. Reported by Richard Telford. - \item \code{metaMDS} and \code{monoMDS} did not accept missing - values in dissimilarities. + \item \code{metaMDS} and \code{monoMDS} rejected dissimilarities + with missing values. \item Function \code{rarecurve} did not check its input and this could cause confusing error messages. Now function checks that @@ -71,10 +71,10 @@ \code{capscale}) and further analysed with \code{permustats} function. - \item Added environmental data set \code{BCI.env} to the Barro - Colorado Island tree data. Most useful variables are the UTM - coordinates of sample plots. Other variables are constant or nearly - constant and of little use in normal analysis. + \item New data set \code{BCI.env} of site information for the Barro + Colorado Island tree community data. Most useful variables are the + UTM coordinates of sample plots. Other variables are constant or + nearly constant and of little use in normal analysis. } } % new features and functions From noreply at r-forge.r-project.org Thu Sep 24 10:40:35 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 24 Sep 2015 10:40:35 +0200 (CEST) Subject: [Vegan-commits] r2968 - www Message-ID: <20150924084035.D180918111F@r-forge.r-project.org> Author: jarioksa Date: 2015-09-24 10:40:35 +0200 (Thu, 24 Sep 2015) New Revision: 2968 Modified: www/NEWS.html Log: tweak NEWS Modified: www/NEWS.html =================================================================== --- www/NEWS.html 2015-09-24 08:39:45 UTC (rev 2967) +++ www/NEWS.html 2015-09-24 08:40:35 UTC (rev 2968) @@ -54,8 +54,8 @@ long expressions. Reported by Richard Telford.

    -
  • metaMDS and monoMDS did not accept missing -values in dissimilarities. +

  • metaMDS and monoMDS rejected dissimilarities +with missing values.

  • Function rarecurve did not check its input and this @@ -89,10 +89,10 @@ function.

  • -
  • Added environmental data set BCI.env to the Barro -Colorado Island tree data. Most useful variables are the UTM -coordinates of sample plots. Other variables are constant or nearly -constant and of little use in normal analysis. +

  • New data set BCI.env of site information for the Barro +Colorado Island tree community data. Most useful variables are the +UTM coordinates of sample plots. Other variables are constant or +nearly constant and of little use in normal analysis.