[Vegan-commits] r874 - in pkg/vegan: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 17 11:48:13 CEST 2009


Author: jarioksa
Date: 2009-06-17 11:48:10 +0200 (Wed, 17 Jun 2009)
New Revision: 874

Added:
   pkg/vegan/R/rrarefy.R
Modified:
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/diversity.Rd
Log:
rrarefy: a new function to produce ranodmly rarefied communities

Added: pkg/vegan/R/rrarefy.R
===================================================================
--- pkg/vegan/R/rrarefy.R	                        (rev 0)
+++ pkg/vegan/R/rrarefy.R	2009-06-17 09:48:10 UTC (rev 874)
@@ -0,0 +1,17 @@
+rrarefy <-
+function(x, sample)
+{
+    if (length(sample) > 1 && length(sample) != nrow(x))
+        stop("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)
+    for (i in 1:nrow(x)) {
+        row <- sample(rep(nm, times=x[i,]), sample[i])
+        row <- table(row)
+        ind <- names(row)
+        x[i,] <- 0
+        x[i,ind] <- row
+    }
+    x
+}

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-06-17 08:17:22 UTC (rev 873)
+++ pkg/vegan/inst/ChangeLog	2009-06-17 09:48:10 UTC (rev 874)
@@ -6,6 +6,9 @@
 
 	* new version opened concurrently with the release of vegan 1.15-3
 	on June 17, 2009.
+
+	* rrarefy: a new function to generate randomly rarefied
+	communities. 
 	
 Version 1.16-19 (closed June 17, 2009)
 

Modified: pkg/vegan/man/diversity.Rd
===================================================================
--- pkg/vegan/man/diversity.Rd	2009-06-17 08:17:22 UTC (rev 873)
+++ pkg/vegan/man/diversity.Rd	2009-06-17 09:48:10 UTC (rev 874)
@@ -2,9 +2,11 @@
 \name{diversity}
 \alias{diversity}
 \alias{rarefy}
+\alias[rrarefy}
 \alias{fisher.alpha}
 \alias{specnumber}
 
+
 \title{ Ecological Diversity Indices and Rarefaction Species Richness }
 
 \description{ Shannon, Simpson, and Fisher diversity indices
@@ -15,6 +17,8 @@
 
 rarefy(x, sample, se = FALSE, MARGIN = 1)
 
+rrarefy(x, sample)
+
 fisher.alpha(x, MARGIN = 1, se = FALSE, ...)
 
 specnumber(x, MARGIN = 1)
@@ -52,8 +56,15 @@
   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).  
+  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}.  
+
   \code{fisher.alpha} estimates the \eqn{\alpha} parameter of
   Fisher's logarithmic series (see \code{\link{fisherfit}}). 
   The estimation is possible only for genuine



More information about the Vegan-commits mailing list