From noreply at r-forge.r-project.org Wed Oct 7 10:22:03 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 7 Oct 2015 10:22:03 +0200 (CEST) Subject: [Vegan-commits] r2969 - in pkg/vegan: . R man Message-ID: <20151007082203.29721187163@r-forge.r-project.org> Author: jarioksa Date: 2015-10-07 10:22:02 +0200 (Wed, 07 Oct 2015) New Revision: 2969 Modified: pkg/vegan/DESCRIPTION pkg/vegan/R/lines.procrustes.R pkg/vegan/R/ordiArgAbsorber.R pkg/vegan/R/points.procrustes.R pkg/vegan/man/procrustes.Rd pkg/vegan/man/vegan-internal.Rd Log: Merge branch 'cran-2.3' into r-forge-svn-local Modified: pkg/vegan/DESCRIPTION =================================================================== --- pkg/vegan/DESCRIPTION 2015-09-24 08:40:35 UTC (rev 2968) +++ pkg/vegan/DESCRIPTION 2015-10-07 08:22:02 UTC (rev 2969) @@ -1,7 +1,7 @@ Package: vegan Title: Community Ecology Package -Version: 2.3-1 -Date: 2015-09-24 +Version: 2.3-2 +Date: 2015-09-25 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/lines.procrustes.R =================================================================== --- pkg/vegan/R/lines.procrustes.R 2015-09-24 08:40:35 UTC (rev 2968) +++ pkg/vegan/R/lines.procrustes.R 2015-10-07 08:22:02 UTC (rev 2969) @@ -1,12 +1,17 @@ -"lines.procrustes" <- - function(x, type=c("segments", "arrows"), choices=c(1,2), ...) +`lines.procrustes` <- + function(x, type=c("segments", "arrows"), choices=c(1,2), + truemean = FALSE, ...) { type <- match.arg(type) X <- x$X[,choices, drop=FALSE] Y <- x$Yrot[, choices, drop=FALSE] + if (truemean) { + X <- sweep(X, 2, x$xmean[choices], "+") + Y <- sweep(Y, 2, x$xmean[choices], "+") + } if (type == "segments") - segments(X[,1], X[,2], Y[,1], Y[,2], ...) + ordiArgAbsorber(X[,1], X[,2], Y[,1], Y[,2], FUN = segments, ...) else - arrows(X[,1], X[,2], Y[,1], Y[,2], ...) + ordiArgAbsorber(X[,1], X[,2], Y[,1], Y[,2], FUN = arrows, ...) invisible() } Modified: pkg/vegan/R/ordiArgAbsorber.R =================================================================== --- pkg/vegan/R/ordiArgAbsorber.R 2015-09-24 08:40:35 UTC (rev 2968) +++ pkg/vegan/R/ordiArgAbsorber.R 2015-10-07 08:22:02 UTC (rev 2969) @@ -1,3 +1,3 @@ `ordiArgAbsorber` <- function(..., shrink, origin, scaling, triangular, - display, choices, const, FUN) + display, choices, const, truemean, FUN) match.fun(FUN)(...) Modified: pkg/vegan/R/points.procrustes.R =================================================================== --- pkg/vegan/R/points.procrustes.R 2015-09-24 08:40:35 UTC (rev 2968) +++ pkg/vegan/R/points.procrustes.R 2015-10-07 08:22:02 UTC (rev 2969) @@ -1,19 +1,27 @@ `points.procrustes` <- - function(x, display = c("target","rotated"), ...) + function(x, display = c("target","rotated"), choices = c(1,2), + truemean = FALSE, ...) { display <- match.arg(display) - x <- if (display == "target") x$X else x$Yrot - points(x, ...) + X <- if (display == "target") x$X else x$Yrot + X <- X[, choices, drop = FALSE] + if (truemean) + X <- sweep(X, 2, x$xmean[choices], "+") + ordiArgAbsorber(X, FUN = points, ...) invisible() } `text.procrustes` <- - function(x, display = c("target","rotated"), labels, ...) + function(x, display = c("target","rotated"), choices = c(1,2), + labels, truemean = FALSE, ...) { display <- match.arg(display) - x <- if (display == "target") x$X else x$Yrot + X <- if (display == "target") x$X else x$Yrot + X <- X[, choices, drop = FALSE] + if (truemean) + X <- sweep(X, 2, x$xmean[choices], "+") if (missing(labels)) - labels <- rownames(x) - text(x, labels = labels, ...) + labels <- rownames(X) + ordiArgAbsorber(X, labels = labels, FUN = text, ...) invisible() } Modified: pkg/vegan/man/procrustes.Rd =================================================================== --- pkg/vegan/man/procrustes.Rd 2015-09-24 08:40:35 UTC (rev 2968) +++ pkg/vegan/man/procrustes.Rd 2015-10-07 08:22:02 UTC (rev 2969) @@ -22,9 +22,12 @@ \method{plot}{procrustes}(x, kind=1, choices=c(1,2), to.target = TRUE, type = "p", xlab, ylab, main, ar.col = "blue", len=0.05, cex = 0.7, ...) -\method{points}{procrustes}(x, display = c("target", "rotated"), ...) -\method{text}{procrustes}(x, display = c("target", "rotated"), labels, ...) -\method{lines}{procrustes}(x, type = c("segments", "arrows"), choices = c(1, 2), ...) +\method{points}{procrustes}(x, display = c("target", "rotated"), + choices = c(1,2), truemean = FALSE, ...) +\method{text}{procrustes}(x, display = c("target", "rotated"), + choices = c(1,2), labels, truemean = FALSE, ...) +\method{lines}{procrustes}(x, type = c("segments", "arrows"), + choices = c(1, 2), truemean = FALSE, ...) \method{residuals}{procrustes}(object, ...) \method{fitted}{procrustes}(object, truemean = TRUE, ...) \method{predict}{procrustes}(object, newdata, truemean = TRUE, ...) @@ -61,7 +64,8 @@ target and rotated configuration.} \item{truemean}{Use the original range of target matrix instead of centring the fitted values. Function \code{plot.procrustes} needs - \code{truemean = FALSE}.} + \code{truemean = FALSE}, and adding graphical items to the plots + from the original results may need \code{truemean = TRUE}.} \item{newdata}{Matrix of coordinates to be rotated and translated to the target.} \item{permutations}{a list of control values for the permutations Modified: pkg/vegan/man/vegan-internal.Rd =================================================================== --- pkg/vegan/man/vegan-internal.Rd 2015-09-24 08:40:35 UTC (rev 2968) +++ pkg/vegan/man/vegan-internal.Rd 2015-10-07 08:22:02 UTC (rev 2969) @@ -27,7 +27,7 @@ ordiNAexclude(x, excluded) ordiNApredict(omit, x) ordiArgAbsorber(..., shrink, origin, scaling, triangular, - display, choices, const, FUN) + display, choices, const, truemean, FUN) centroids.cca(x, mf, wt) getPermuteMatrix(perm, N, strata = NULL) howHead(x, ...) From noreply at r-forge.r-project.org Fri Oct 9 08:01:44 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 9 Oct 2015 08:01:44 +0200 (CEST) Subject: [Vegan-commits] r2970 - in pkg/vegan: R man Message-ID: <20151009060145.076CA184860@r-forge.r-project.org> Author: jarioksa Date: 2015-10-09 08:01:44 +0200 (Fri, 09 Oct 2015) New Revision: 2970 Modified: pkg/vegan/R/rrarefy.R pkg/vegan/man/rarefy.Rd Log: Merge branch 'cran-2.3' into r-forge-svn-local Modified: pkg/vegan/R/rrarefy.R =================================================================== --- pkg/vegan/R/rrarefy.R 2015-10-07 08:22:02 UTC (rev 2969) +++ pkg/vegan/R/rrarefy.R 2015-10-09 06:01:44 UTC (rev 2970) @@ -14,7 +14,12 @@ sample <- rep(sample, length=nrow(x)) colnames(x) <- colnames(x, do.NULL = FALSE) nm <- colnames(x) + ## warn if something cannot be rarefied + if (any(rowSums(x) < sample)) + warning("Some row sums < 'sample' and are not rarefied") for (i in 1:nrow(x)) { + if (sum(x[i,]) <= sample[i]) ## nothing to rarefy: take all + next row <- sample(rep(nm, times=x[i,]), sample[i]) row <- table(row) ind <- names(row) @@ -33,12 +38,19 @@ stop("function accepts only integers (counts)") if (length(sample) > 1 && length(sample) != nrow(x)) stop(gettextf( - "length of 'sample' and number of rows of 'x' do not match")) + "length of 'sample' and number of rows of 'x' do not match")) x <- drop(as.matrix(x)) + ## warn on too large samples + if (is.matrix(x)) + rs <- rowSums(x) + else + rs <- sum(x) + if (any(rs) < sample) + warning("Some row sums < 'sample' and probabilities either 0 or 1") ## dfun is kluge: first item of vector x must be the sample size, ## and the rest is the community data. This seemed an easy trick ## to evaluate dfun in an apply() instead of a loop. - dfun <- function(x, sample) { + dfun <- function(x) { J <- sum(x[-1]) sample <- min(x[1], J) 1 - exp(lchoose(J - x[-1], sample) - lchoose(J, sample)) Modified: pkg/vegan/man/rarefy.Rd =================================================================== --- pkg/vegan/man/rarefy.Rd 2015-10-07 08:22:02 UTC (rev 2969) +++ pkg/vegan/man/rarefy.Rd 2015-10-09 06:01:44 UTC (rev 2970) @@ -47,17 +47,20 @@ \code{rarefy} is based on Hurlbert's (1971) formulation, and the standard errors on Heck et al. (1975). - Function \code{rrarefy} generates one randomly rarefied community data - frame or vector of given \code{sample} size. The \code{sample} can be - a vector giving the sample sizes for each row, and its values must be - less or equal to observed number of individuals. The random - rarefaction is made without replacement so that the variance of - rarefied communities is rather related to rarefaction proportion than - to to the size of the \code{sample}. + Function \code{rrarefy} generates one randomly rarefied community + data frame or vector of given \code{sample} size. The \code{sample} + can be a vector giving the sample sizes for each row. If the + \code{sample} size is equal to or smaller than the observed number + of individuals, the non-rarefied community will be returned. The + random rarefaction is made without replacement so that the variance + of rarefied communities is rather related to rarefaction proportion + than to the size of the \code{sample}. - Function \code{drarefy} returns probabilities that species occur in a - rarefied community of size \code{sample}. The \code{sample} can be a - vector giving the sample sizes for each row. + Function \code{drarefy} returns probabilities that species occur in + a rarefied community of size \code{sample}. The \code{sample} can be + a vector giving the sample sizes for each row. If the \code{sample} + is equal to or smaller than the observed number of individuals, all + observed species will have sampling probability 1. Function \code{rarecurve} draws a rarefaction curve for each row of the input data. The rarefaction curves are evaluated using the From noreply at r-forge.r-project.org Thu Oct 15 14:42:29 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 15 Oct 2015 14:42:29 +0200 (CEST) Subject: [Vegan-commits] r2971 - pkg/vegan/R Message-ID: <20151015124229.35B85186886@r-forge.r-project.org> Author: jarioksa Date: 2015-10-15 14:42:28 +0200 (Thu, 15 Oct 2015) New Revision: 2971 Modified: pkg/vegan/R/ordiellipse.R Log: Merge branch 'cran-2.3' into r-forge-svn-local Modified: pkg/vegan/R/ordiellipse.R =================================================================== --- pkg/vegan/R/ordiellipse.R 2015-10-09 06:01:44 UTC (rev 2970) +++ pkg/vegan/R/ordiellipse.R 2015-10-15 12:42:28 UTC (rev 2971) @@ -42,7 +42,7 @@ W <- w[gr] mat <- cov.wt(X, W) if (kind == "se") - mat$cov <- mat$cov/mat$n.obs + mat$cov <- mat$cov * sum(mat$wt^2) if (missing(conf)) t <- 1 else t <- sqrt(qchisq(conf, 2)) From noreply at r-forge.r-project.org Fri Oct 23 11:33:00 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 23 Oct 2015 11:33:00 +0200 (CEST) Subject: [Vegan-commits] r2972 - pkg/vegan/R Message-ID: <20151023093300.CAF9F1850A5@r-forge.r-project.org> Author: jarioksa Date: 2015-10-23 11:33:00 +0200 (Fri, 23 Oct 2015) New Revision: 2972 Modified: pkg/vegan/R/ordicluster.R Log: Merge branch 'cran-2.3' into r-forge-svn-local Modified: pkg/vegan/R/ordicluster.R =================================================================== --- pkg/vegan/R/ordicluster.R 2015-10-15 12:42:28 UTC (rev 2971) +++ pkg/vegan/R/ordicluster.R 2015-10-23 09:33:00 UTC (rev 2972) @@ -1,4 +1,4 @@ -"ordicluster" <- +`ordicluster` <- function (ord, cluster, prune=0, display="sites", w = weights(ord, display), ...) { @@ -10,19 +10,20 @@ stop("Dimensions do not match in 'ord' and 'cluster'") if (length(w) == 1) w <- rep(w, nrow(ord)) n <- if (is.null(w)) rep(1, nrow(ord)) else w + noden <- numeric(nrow(ord)) go <- ord for (i in 1: (nrow(mrg) - prune)) { a <- mrg[i,1] b <- mrg[i,2] one <- if (a < 0) ord[-a,] else go[a,] two <- if (b < 0) ord[-b,] else go[b,] - n1 <- if (a < 0) n[-a] else n[a] - n2 <- if (b < 0) n[-b] else n[b] + n1 <- if (a < 0) n[-a] else noden[a] + n2 <- if (b < 0) n[-b] else noden[b] ordiArgAbsorber(one[1], one[2], two[1], two[2], FUN = segments, ...) xm <- weighted.mean(c(one[1],two[1]), w=c(n1,n2)) ym <- weighted.mean(c(one[2],two[2]), w=c(n1,n2)) go[i,] <- c(xm,ym) - n[i] <- n1 + n2 + noden[i] <- n1 + n2 } - invisible(cbind(go, "w"=n)) + invisible(cbind(go, "w"=noden)) }