[Vegan-commits] r1530 - in branches/1.17: . R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Mar 9 15:28:02 CET 2011
Author: jarioksa
Date: 2011-03-09 15:28:01 +0100 (Wed, 09 Mar 2011)
New Revision: 1530
Modified:
branches/1.17/DESCRIPTION
branches/1.17/R/as.preston.R
branches/1.17/R/diversity.R
branches/1.17/R/prestonfit.R
branches/1.17/R/rarefy.R
branches/1.17/R/rrarefy.R
branches/1.17/R/specnumber.R
branches/1.17/inst/ChangeLog
branches/1.17/man/CCorA.Rd
branches/1.17/man/diversity.Rd
branches/1.17/man/envfit.Rd
branches/1.17/man/fisherfit.Rd
branches/1.17/man/ordihull.Rd
Log:
merge r1499, 1521 thru 1529 to release branches/
Modified: branches/1.17/DESCRIPTION
===================================================================
--- branches/1.17/DESCRIPTION 2011-03-09 06:36:58 UTC (rev 1529)
+++ branches/1.17/DESCRIPTION 2011-03-09 14:28:01 UTC (rev 1530)
@@ -1,7 +1,7 @@
Package: vegan
Title: Community Ecology Package
-Version: 1.17-8
-Date: March 2, 2011
+Version: 1.17-9
+Date: March 9, 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
Modified: branches/1.17/R/as.preston.R
===================================================================
--- branches/1.17/R/as.preston.R 2011-03-09 06:36:58 UTC (rev 1529)
+++ branches/1.17/R/as.preston.R 2011-03-09 14:28:01 UTC (rev 1530)
@@ -1,5 +1,5 @@
`as.preston` <-
- function (x, tiesplit = FALSE, ...)
+ function (x, tiesplit = TRUE, ...)
{
if (inherits(x, "preston"))
return(x)
Modified: branches/1.17/R/diversity.R
===================================================================
--- branches/1.17/R/diversity.R 2011-03-09 06:36:58 UTC (rev 1529)
+++ branches/1.17/R/diversity.R 2011-03-09 14:28:01 UTC (rev 1530)
@@ -1,16 +1,23 @@
`diversity` <-
function (x, index = "shannon", MARGIN = 1, base = exp(1))
{
- x <- as.matrix(x)
+ x <- drop(as.matrix(x))
INDICES <- c("shannon", "simpson", "invsimpson")
index <- match.arg(index, INDICES)
- total <- apply(x, MARGIN, sum)
- x <- sweep(x, MARGIN, total, "/")
+ if (length(dim(x)) > 1) {
+ total <- apply(x, MARGIN, sum)
+ x <- sweep(x, MARGIN, total, "/")
+ } else {
+ x <- x/sum(x)
+ }
if (index == "shannon")
x <- -x * log(x, base)
else
- x <- x^2
- H <- apply(x, MARGIN, sum, na.rm = TRUE)
+ x <- x*x
+ if (length(dim(x)) > 1)
+ H <- apply(x, MARGIN, sum, na.rm = TRUE)
+ else
+ H <- sum(x, na.rm = TRUE)
if (index == "simpson")
H <- 1 - H
else if (index == "invsimpson")
Modified: branches/1.17/R/prestonfit.R
===================================================================
--- branches/1.17/R/prestonfit.R 2011-03-09 06:36:58 UTC (rev 1529)
+++ branches/1.17/R/prestonfit.R 2011-03-09 14:28:01 UTC (rev 1530)
@@ -1,5 +1,5 @@
`prestonfit` <-
- function (x, tiesplit = FALSE, ...)
+ function (x, tiesplit = TRUE, ...)
{
x <- as.preston(x, tiesplit = tiesplit)
oct <- as.numeric(names(x))
Modified: branches/1.17/R/rarefy.R
===================================================================
--- branches/1.17/R/rarefy.R 2011-03-09 06:36:58 UTC (rev 1529)
+++ branches/1.17/R/rarefy.R 2011-03-09 14:28:01 UTC (rev 1530)
@@ -2,6 +2,9 @@
function (x, sample, se = FALSE, MARGIN = 1)
{
x <- as.matrix(x)
+ ## as.matrix changes an n-vector to a n x 1 matrix
+ if (ncol(x) == 1 && MARGIN == 1)
+ x <- t(x)
if (!identical(all.equal(x, round(x)), TRUE))
stop("function accepts only integers (counts)")
if (missing(sample)) {
Modified: branches/1.17/R/rrarefy.R
===================================================================
--- branches/1.17/R/rrarefy.R 2011-03-09 06:36:58 UTC (rev 1529)
+++ branches/1.17/R/rrarefy.R 2011-03-09 14:28:01 UTC (rev 1530)
@@ -1,8 +1,14 @@
-rrarefy <-
-function(x, sample)
+### Random rarefied subsample: sample without replacement
+
+`rrarefy` <-
+ function(x, sample)
{
+ x <- as.matrix(x)
+ if (ncol(x) == 1)
+ x <- t(x)
if (length(sample) > 1 && length(sample) != nrow(x))
- stop("length of 'sample' and number of rows of 'x' do not match")
+ stop(gettextf,
+ "length of 'sample' and number of rows of 'x' do not match")
sample <- rep(sample, length=nrow(x))
colnames(x) <- colnames(x, do.NULL = FALSE)
nm <- colnames(x)
@@ -15,3 +21,26 @@
}
x
}
+
+### Probabilities that species occur in a rarefied 'sample'
+
+`drarefy` <-
+ function(x, sample)
+{
+ if (length(sample) > 1 && length(sample) != nrow(x))
+ stop(gettextf,
+ "length of 'sample' and number of rows of 'x' do not match")
+ x <- drop(as.matrix(x))
+ ## 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) {
+ J <- sum(x[-1])
+ sample <- min(x[1], J)
+ 1 - exp(lchoose(J - x[-1], sample) - lchoose(J, sample))
+ }
+ if (length(dim(x)) > 1)
+ t(apply(cbind(sample, x), 1, dfun))
+ else
+ dfun(c(sample, x))
+}
Modified: branches/1.17/R/specnumber.R
===================================================================
--- branches/1.17/R/specnumber.R 2011-03-09 06:36:58 UTC (rev 1529)
+++ branches/1.17/R/specnumber.R 2011-03-09 14:28:01 UTC (rev 1530)
@@ -1,5 +1,8 @@
-"specnumber" <-
+`specnumber` <-
function(x, MARGIN = 1)
{
- apply(x > 0, MARGIN, sum)
+ if (length(dim(x)) > 1)
+ apply(x > 0, MARGIN, sum)
+ else
+ sum(x > 0)
}
Modified: branches/1.17/inst/ChangeLog
===================================================================
--- branches/1.17/inst/ChangeLog 2011-03-09 06:36:58 UTC (rev 1529)
+++ branches/1.17/inst/ChangeLog 2011-03-09 14:28:01 UTC (rev 1530)
@@ -2,6 +2,17 @@
VEGAN RELEASE VERSIONS at http://cran.r-project.org/
+Version 1.17-9 (opened March 9, 2011)
+
+ * merged r1527,8: doc updates in CCorA.Rd & ordihull.Rd.
+
+ * merged r1522 thru r1526: implement drarefy; drarefy, rrarefy,
+ specnumber, diversity accept vector input.
+
+ * merged r1521: clarify envfit.Rd.
+
+ * merged r1499: as.preston, preston default to 'tiesplit = TRUE'.
+
Version 1.17-8 (released March 2, 2011)
* merged r1494: no return.
Modified: branches/1.17/man/CCorA.Rd
===================================================================
--- branches/1.17/man/CCorA.Rd 2011-03-09 06:36:58 UTC (rev 1529)
+++ branches/1.17/man/CCorA.Rd 2011-03-09 14:28:01 UTC (rev 1530)
@@ -131,7 +131,6 @@
rownames(mite.hel.2) = paste("S",1:nrow(mite),sep="")
out <- CCorA(mite.hel.1, mite.hel.2)
out
-summary(out)
biplot(out, "ob") # Two plots of objects
biplot(out, "v", cex=c(0.7,0.6)) # Two plots of variables
biplot(out, "ov", cex=c(0.7,0.6)) # Four plots (2 for objects, 2 for variables)
Modified: branches/1.17/man/diversity.Rd
===================================================================
--- branches/1.17/man/diversity.Rd 2011-03-09 06:36:58 UTC (rev 1529)
+++ branches/1.17/man/diversity.Rd 2011-03-09 14:28:01 UTC (rev 1530)
@@ -3,6 +3,7 @@
\alias{diversity}
\alias{rarefy}
\alias{rrarefy}
+\alias{drarefy}
\alias{fisher.alpha}
\alias{specnumber}
@@ -13,18 +14,15 @@
\usage{
diversity(x, index = "shannon", MARGIN = 1, base = exp(1))
-
rarefy(x, sample, se = FALSE, MARGIN = 1)
-
rrarefy(x, sample)
-
+drarefy(x, sample)
fisher.alpha(x, MARGIN = 1, se = FALSE, ...)
-
specnumber(x, MARGIN = 1)
}
\arguments{
- \item{x}{Community data, a matrix-like object.}
+ \item{x}{Community data, a matrix-like object or a vector.}
\item{index}{Diversity index, one of \code{"shannon"},
\code{"simpson"} or \code{"invsimpson"}.}
\item{MARGIN}{Margin for which the index is computed. }
@@ -49,21 +47,26 @@
Function \code{rarefy} gives the expected species richness in random
subsamples of size \code{sample} from the community. The size of
\code{sample} should be smaller than total community size, but the
- function will silently work for larger \code{sample} as well and
+ function will silently work for larger \code{sample} as well and
return non-rarefied species richness (and standard error = 0). If
- \code{sample} is a vector, rarefaction is performed for each sample
- size separately.
- Rarefaction can be performed only with genuine counts of individuals.
- The function \code{rarefy} is based on Hurlbert's (1971) formulation,
- and the standard errors on Heck et al. (1975).
+ \code{sample} is a vector, rarefaction of all observations is
+ performed for each sample size separately. Rarefaction can be
+ performed only with genuine counts of individuals. The function
+ \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, 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}.
+ 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{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.
+
\code{fisher.alpha} estimates the \eqn{\alpha} parameter of
Fisher's logarithmic series (see \code{\link{fisherfit}}).
The estimation is possible only for genuine
Modified: branches/1.17/man/envfit.Rd
===================================================================
--- branches/1.17/man/envfit.Rd 2011-03-09 06:36:58 UTC (rev 1529)
+++ branches/1.17/man/envfit.Rd 2011-03-09 14:28:01 UTC (rev 1530)
@@ -42,8 +42,10 @@
\item{permutations}{ Number of permutations for assessing significance
of vectors or factors. Set to \code{0} to skip permutations.}
\item{formula, data}{Model \code{\link{formula}} and data. }
- \item{na.rm}{Remove points with missing values in ordination scores or
- environmental variables}.
+ \item{na.rm}{Remove points with missing values in ordination scores
+ or environmental variables. The operation is casewise: the whole
+ row of data is removed if there is a missing value and
+ \code{na.rm = TRUE}.}
\item{x}{A result object from \code{envfit}.}
\item{choices}{Axes to plotted.}
\item{arrow.mul}{Multiplier for vector lengths. The arrows are
Modified: branches/1.17/man/fisherfit.Rd
===================================================================
--- branches/1.17/man/fisherfit.Rd 2011-03-09 06:36:58 UTC (rev 1529)
+++ branches/1.17/man/fisherfit.Rd 2011-03-09 14:28:01 UTC (rev 1530)
@@ -27,14 +27,14 @@
\method{confint}{fisherfit}(object, parm, level = 0.95, ...)
\method{profile}{fisherfit}(fitted, alpha = 0.01, maxsteps = 20, del = zmax/5,
...)
-prestonfit(x, tiesplit = FALSE, ...)
+prestonfit(x, tiesplit = TRUE, ...)
prestondistr(x, truncate = -1, ...)
\method{plot}{prestonfit}(x, xlab = "Frequency", ylab = "Species", bar.col = "skyblue",
line.col = "red", lwd = 2, ...)
\method{lines}{prestonfit}(x, line.col = "red", lwd = 2, ...)
veiledspec(x, ...)
as.fisher(x, ...)
-as.preston(x, tiesplit = FALSE, ...)
+as.preston(x, tiesplit = TRUE, ...)
}
\arguments{
Modified: branches/1.17/man/ordihull.Rd
===================================================================
--- branches/1.17/man/ordihull.Rd 2011-03-09 06:36:58 UTC (rev 1529)
+++ branches/1.17/man/ordihull.Rd 2011-03-09 14:28:01 UTC (rev 1530)
@@ -104,7 +104,7 @@
the items in the groups.
Function \code{ordiellipse} draws \code{\link{lines}} or
- \code{\link{polygon}}s for dispersion \code{\link[ellipse]{ellipse}}
+ \code{\link{polygon}}s for dispersion ellipses
using either standard deviation of point scores or standard error of
the (weighted) average of scores, and the (weighted) correlation
defines the direction of the principal axis of the ellipse.
More information about the Vegan-commits
mailing list