From noreply at r-forge.r-project.org Sat Mar 15 17:27:27 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 15 Mar 2014 17:27:27 +0100 (CET) Subject: [Vegan-commits] r2862 - in pkg/vegan: R inst Message-ID: <20140315162727.48B41186AAC@r-forge.r-project.org> Author: gsimpson Date: 2014-03-15 17:27:26 +0100 (Sat, 15 Mar 2014) New Revision: 2862 Modified: pkg/vegan/R/plot.envfit.R pkg/vegan/inst/ChangeLog Log: handle case where there are no useful rownames stored and labels is a vector input Modified: pkg/vegan/R/plot.envfit.R =================================================================== --- pkg/vegan/R/plot.envfit.R 2014-02-21 10:41:49 UTC (rev 2861) +++ pkg/vegan/R/plot.envfit.R 2014-03-15 16:27:26 UTC (rev 2862) @@ -19,9 +19,12 @@ ## and the existing set of labels is replaced if (!is.null(labs$v) && !is.null(labs$f)) stop("needs a list with both 'vectors' and 'factors' labels") - if (!is.null(labs$v)) + ## need to handle the case where both sets of labels are NULL + ## such as when used with the default interface and single x + ln <- sapply(labs, is.null) + if (ln["v"]) labs$v <- labels - else + if (ln["f"]) labs$f <- labels } } @@ -102,7 +105,7 @@ xlim <- range(xstack[,1] + sw, xstack[,2] - sw) ylim <- range(xstack[,2] + sh, xstack[,2] - sh) plot.window(xlim = xlim, ylim = ylim, asp = 1, ...) - ## Re-evaluate arrow.mul, set its text and re-evaluate limits again + ## Re-evaluate arrow.mul, set its text and re-evaluate limits again if (!is.null(vect)) { arrow.mul <- ordiArrowMul(vect, at = at, fill = 1) vect <- arrow.mul * vect @@ -119,7 +122,7 @@ alabs <- colnames(vect) title(..., ylab = alabs[2], xlab = alabs[1]) } - + if (!is.null(vect)) { arrows(at[1], at[2], vect[, 1], vect[, 2], len = 0.05, col = col) Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2014-02-21 10:41:49 UTC (rev 2861) +++ pkg/vegan/inst/ChangeLog 2014-03-15 16:27:26 UTC (rev 2862) @@ -105,7 +105,12 @@ Flavniva). In addition, Dip.mon was corrected to Diphcomp (Diphasiastrum complanatum, should perhaps be Lycopodium c.), and Barbilophozia lycopodioides to B. hatcheri. - + + * plot.envfit: when `envfit()` is called as + `envfit(ord, foo[, "bar"])`, there are no useful rownames on the + objects returned. Hence the logic in `plot.envfit()` when called + with argument `labels` was failing. + Version 2.1-40 (closed December 12, 2013) * anova.cca: Function is now based on the new code, but the old is From noreply at r-forge.r-project.org Sat Mar 22 07:57:05 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 22 Mar 2014 07:57:05 +0100 (CET) Subject: [Vegan-commits] r2863 - pkg/vegan Message-ID: <20140322065705.BD6B61867F3@r-forge.r-project.org> Author: jarioksa Date: 2014-03-22 07:57:05 +0100 (Sat, 22 Mar 2014) New Revision: 2863 Modified: pkg/vegan/NAMESPACE Log: forgot to export panel.ordiarrows Modified: pkg/vegan/NAMESPACE =================================================================== --- pkg/vegan/NAMESPACE 2014-03-15 16:27:26 UTC (rev 2862) +++ pkg/vegan/NAMESPACE 2014-03-22 06:57:05 UTC (rev 2863) @@ -49,7 +49,7 @@ rgl.renyiaccum, vif.cca) ## Export panel functions -export(panel.ordi, panel.ordi3d, prepanel.ordi3d) +export(panel.ordi, panel.ordiarrows, panel.ordi3d, prepanel.ordi3d) ## Export .Depracated functions (to be removed later) export(metaMDSrotate) From noreply at r-forge.r-project.org Sun Mar 23 20:34:54 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 23 Mar 2014 20:34:54 +0100 (CET) Subject: [Vegan-commits] r2864 - in pkg/vegan: R inst Message-ID: <20140323193454.8FF1E186D18@r-forge.r-project.org> Author: jarioksa Date: 2014-03-23 20:34:54 +0100 (Sun, 23 Mar 2014) New Revision: 2864 Modified: pkg/vegan/R/tabasco.R pkg/vegan/inst/ChangeLog Log: take care that names match in clusters and data in tabasco Modified: pkg/vegan/R/tabasco.R =================================================================== --- pkg/vegan/R/tabasco.R 2014-03-22 06:57:05 UTC (rev 2863) +++ pkg/vegan/R/tabasco.R 2014-03-23 19:34:54 UTC (rev 2864) @@ -28,6 +28,15 @@ } if (!is.null(site.ind)) stop("'site.ind' cannot be used with dendrogram") + ## The tree/dendrogam and input data must be ordered + ## identically. It could be regarded as a "user error" if + ## they are not, but this could be really frustrating and + ## give obscure errors, and therefore we take care of + ## identical ordering here + if (inherits(use, "hclust") && !is.null(hclust$labels)) + x <- x[use$labels,] + else # dendrogram + x <- x[labels(use),] ## Reorder tree if Rowv specified if (isTRUE(Rowv)) { ## order by first CA axis -- decorana() is fastest @@ -83,6 +92,11 @@ sp.ind <- as.dendrogram(sp.ind) } sptree <- sp.ind + ## Reorder data to match order in the dendrogam (see 'use' above) + if (inherits(sptree, "hclust")) + x <- x[, sptree$labels] + else # dendrogram + x <- x[, labels(sptree)] ## Consider reordering species tree if (isTRUE(Colv) && !is.null(site.ind)) { sptree <- reorder(sptree, wascores(order(site.ind), x), Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2014-03-22 06:57:05 UTC (rev 2863) +++ pkg/vegan/inst/ChangeLog 2014-03-23 19:34:54 UTC (rev 2864) @@ -56,7 +56,10 @@ used for reordering of dendrograms. Earlier "hclust" objects were changed to dendrograms, but now we provide reorder.hclust() and rev.hclust() in vegan, and can use improved method of ordering the - table. + table. Dendrogram and hclust labels must match the community data + names, and now the community matrix is internally reordered to + match the dendrograms. This requires that the clusterings do have + labels attributes. * treedive, treedist: default is now match.force = TRUE, and treedive() gained new argument 'verbose' to turn of most messages From noreply at r-forge.r-project.org Sun Mar 23 21:01:12 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 23 Mar 2014 21:01:12 +0100 (CET) Subject: [Vegan-commits] r2865 - pkg/vegan/R Message-ID: <20140323200112.E584A186D20@r-forge.r-project.org> Author: jarioksa Date: 2014-03-23 21:01:12 +0100 (Sun, 23 Mar 2014) New Revision: 2865 Modified: pkg/vegan/R/tabasco.R Log: fix carelessness of previus commit Modified: pkg/vegan/R/tabasco.R =================================================================== --- pkg/vegan/R/tabasco.R 2014-03-23 19:34:54 UTC (rev 2864) +++ pkg/vegan/R/tabasco.R 2014-03-23 20:01:12 UTC (rev 2865) @@ -33,7 +33,7 @@ ## they are not, but this could be really frustrating and ## give obscure errors, and therefore we take care of ## identical ordering here - if (inherits(use, "hclust") && !is.null(hclust$labels)) + if (inherits(use, "hclust") && !is.null(use$labels)) x <- x[use$labels,] else # dendrogram x <- x[labels(use),] From noreply at r-forge.r-project.org Fri Mar 28 11:04:53 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 28 Mar 2014 11:04:53 +0100 (CET) Subject: [Vegan-commits] r2866 - in pkg/vegan: R inst Message-ID: <20140328100454.0AB4C18732B@r-forge.r-project.org> Author: jarioksa Date: 2014-03-28 11:04:53 +0100 (Fri, 28 Mar 2014) New Revision: 2866 Modified: pkg/vegan/R/fitted.radfit.R pkg/vegan/R/radfit.data.frame.R pkg/vegan/inst/ChangeLog Log: radfit plots work for sites with one or no species Modified: pkg/vegan/R/fitted.radfit.R =================================================================== --- pkg/vegan/R/fitted.radfit.R 2014-03-23 20:01:12 UTC (rev 2865) +++ pkg/vegan/R/fitted.radfit.R 2014-03-28 10:04:53 UTC (rev 2866) @@ -1,7 +1,13 @@ `fitted.radfit` <- function(object, ...) { - sapply(object$models, fitted) + out <- sapply(object$models, fitted) + if (!length(object$y)) + out <- numeric(length(object$models)) + if (length(object$y) <= 1) + out <- structure(as.vector(out), dim = c(1, length(object$models)), + dimnames = list(names(object$y), names(object$models))) + out } `fitted.radfit.frame` <- Modified: pkg/vegan/R/radfit.data.frame.R =================================================================== --- pkg/vegan/R/radfit.data.frame.R 2014-03-23 20:01:12 UTC (rev 2865) +++ pkg/vegan/R/radfit.data.frame.R 2014-03-28 10:04:53 UTC (rev 2866) @@ -3,6 +3,12 @@ { ## x *must* have rownames rownames(x) <- rownames(x, do.NULL = TRUE) + ## remove empty rows with no species + nspec <- specnumber(x) + if (any(nspec == 0)) { + warning("removed empty rows with no species") + x <- x[nspec>0,, drop=FALSE] + } out <- apply(x, 1, radfit, ...) if (length(out) == 1) out <- out[[1]] Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2014-03-23 20:01:12 UTC (rev 2865) +++ pkg/vegan/inst/ChangeLog 2014-03-28 10:04:53 UTC (rev 2866) @@ -51,6 +51,12 @@ with three points was reported by Paul Bacquet (Louvain, Belgium). + * radfit: plotting of radfit frames of several communuties failed + if there were one-species or no-species (empty) rows. Part of this + was fitted.radfit that now returns sensible and consistent output + for these cases as well, and radfit.data.frame() completely + removes empty rows from the data (with a warning). + * tabasco: "hclust" objects (use, sp.ind) are reordered using weighted means. This is a better method than the unweighted means used for reordering of dendrograms. Earlier "hclust" objects were From noreply at r-forge.r-project.org Sun Mar 30 00:12:51 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 30 Mar 2014 00:12:51 +0100 (CET) Subject: [Vegan-commits] r2867 - in pkg/vegan: R inst man Message-ID: <20140329231251.415981855BE@r-forge.r-project.org> Author: gsimpson Date: 2014-03-30 00:12:50 +0100 (Sun, 30 Mar 2014) New Revision: 2867 Modified: pkg/vegan/R/rarecurve.R pkg/vegan/inst/ChangeLog pkg/vegan/man/diversity.Rd Log: allow setting of per sample rarefaction line colour and type in rarecurve Modified: pkg/vegan/R/rarecurve.R =================================================================== --- pkg/vegan/R/rarecurve.R 2014-03-28 10:04:53 UTC (rev 2866) +++ pkg/vegan/R/rarecurve.R 2014-03-29 23:12:50 UTC (rev 2867) @@ -1,10 +1,18 @@ `rarecurve` <- function(x, step = 1, sample, xlab = "Sample Size", ylab = "Species", - label = TRUE,...) + label = TRUE, col, lty, ...) { + ## sort out col and lty + if (missing(col)) + col <- par("col") + if (missing(lty)) + lty <- par("lty") tot <- rowSums(x) S <- specnumber(x) nr <- nrow(x) + ## rep col and lty to appropriate length + col <- rep(col, length.out = nr) + lty <- rep(lty, length.out = nr) ## Rarefy out <- lapply(seq_len(nr), function(i) { n <- seq(1, tot[i], by = step) @@ -25,9 +33,9 @@ abline(h = rare, lwd=0.5) } ## rarefaction curves - for(ln in seq_len(length(out))) { + for (ln in seq_len(length(out))) { N <- attr(out[[ln]], "Subsample") - lines(N, out[[ln]], ...) + lines(N, out[[ln]], col = col[ln], lty = lty[ln], ...) } ## label curves at their endpoitns if (label) { Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2014-03-28 10:04:53 UTC (rev 2866) +++ pkg/vegan/inst/ChangeLog 2014-03-29 23:12:50 UTC (rev 2867) @@ -4,7 +4,7 @@ Version 2.1-41 (opened December 12, 2013) - * adipart, multipart, hiersimu: it is now an error to provide + * adipart, multipart, hiersimu: it is now an error to provide non-nested sampling hierarchy (used to be a warning). * new version opened with the CRAN release of vegan_2.0-10 on @@ -120,6 +120,10 @@ objects returned. Hence the logic in `plot.envfit()` when called with argument `labels` was failing. + * rarecurve: line colour and type for each sample can now be + specified through formal arguments `col` and `lty`. Incidental + wish of http://stackoverflow.com/q/22714775/429846. + Version 2.1-40 (closed December 12, 2013) * anova.cca: Function is now based on the new code, but the old is Modified: pkg/vegan/man/diversity.Rd =================================================================== --- pkg/vegan/man/diversity.Rd 2014-03-28 10:04:53 UTC (rev 2866) +++ pkg/vegan/man/diversity.Rd 2014-03-29 23:12:50 UTC (rev 2867) @@ -19,7 +19,7 @@ rrarefy(x, sample) drarefy(x, sample) rarecurve(x, step = 1, sample, xlab = "Sample Size", ylab = "Species", - label = TRUE, ...) + label = TRUE, col, lty, ...) fisher.alpha(x, MARGIN = 1, ...) specnumber(x, groups, MARGIN = 1) } @@ -35,7 +35,11 @@ \item{se}{Estimate standard errors.} \item{step}{Step size for sample sizes in rarefaction curves.} \item{xlab, ylab}{Axis labels in plots of rarefaction curves.} - \item{label}{Label rarefaction curves by rownames of \code{x} (logical).} + \item{label}{Label rarefaction curves by rownames of \code{x} + (logical).} + \item{col, lty}{plotting colour and line type, see + \code{\link{par}}. Can be a vector of length \code{nrow(x)}, one per + sample, and will be extended to such a length internally.} \item{groups}{A grouping factor: if given, finds the total number of species in each group.} \item{...}{Parameters passed to \code{\link{nlm}}, or to \code{\link{plot}},