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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Nov 8 14:22:06 CET 2013


Author: jarioksa
Date: 2013-11-08 14:22:06 +0100 (Fri, 08 Nov 2013)
New Revision: 2679

Modified:
   pkg/vegan/R/plot.renyiaccum.R
   pkg/vegan/R/renyiaccum.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/renyi.Rd
Log:
renyiaccum gained a collector curve to be used with summary of permutations

Modified: pkg/vegan/R/plot.renyiaccum.R
===================================================================
--- pkg/vegan/R/plot.renyiaccum.R	2013-11-08 10:40:12 UTC (rev 2678)
+++ pkg/vegan/R/plot.renyiaccum.R	2013-11-08 13:22:06 UTC (rev 2679)
@@ -1,7 +1,9 @@
 `plot.renyiaccum` <-
-function (x, what=c("mean", "Qnt 0.025", "Qnt 0.975"), type = "l", ...) 
+function (x, what=c("Collector", "mean", "Qnt 0.025", "Qnt 0.975"),
+          type = "l", ...) 
 {
-	if (any(what %in% colnames(x[,1,])))
+        what <- what[what %in% dimnames(x)[[3]]]
+	if (any(what %in% dimnames(x)[[3]]))
 	    x <- x[,,what, drop = FALSE]
 	dm <- dim(x)
         dnam <- dimnames(x)

Modified: pkg/vegan/R/renyiaccum.R
===================================================================
--- pkg/vegan/R/renyiaccum.R	2013-11-08 10:40:12 UTC (rev 2678)
+++ pkg/vegan/R/renyiaccum.R	2013-11-08 13:22:06 UTC (rev 2679)
@@ -1,6 +1,6 @@
 `renyiaccum` <-
 function(x, scales=c(0, 0.5, 1, 2, 4, Inf), permutations = 100,
-         raw = FALSE, subset, ...)
+         raw = FALSE, collector = FALSE, subset, ...)
 {
     if (!missing(subset))
         x <- subset(x, subset)
@@ -20,12 +20,16 @@
         result[,,k] <- as.matrix(renyi((apply(x[sample(n),],2,cumsum)),
                                        scales=scales, ...))
     }
+    if (raw)
+        collector <- FALSE
+    if (collector)
+        ref <- as.matrix(renyi(apply(x, 2, cumsum), scales = scales, ...))
     if (raw) {
         if (m==1) {
             result <- result[,1,]
         }
     }else{
-        tmp <- array(dim=c(n,m,6))
+        tmp <- array(dim=c(n,m,6 + as.numeric(collector)))
         for (i in 1:n) {
             for (j in 1:m) {
                 tmp[i,j,1] <- mean(result[i,j,1:permutations]) 
@@ -34,12 +38,14 @@
                 tmp[i,j,4] <- max(result[i,j,1:permutations])
                 tmp[i,j,5] <- quantile(result[i,j,1:permutations],0.025)
                 tmp[i,j,6] <- quantile(result[i,j,1:permutations],0.975)
+                if (collector)
+                    tmp[i,j,7] <- ref[i,j]
             }
         }
         result <- tmp
         dimnames(result) <- list(pooled.sites=c(1:n),
                                   scale=scales,
-                                  c("mean", "stdev", "min", "max", "Qnt 0.025", "Qnt 0.975"))
+                                  c("mean", "stdev", "min", "max", "Qnt 0.025", "Qnt 0.975", if (collector) "Collector"))
     }
     class(result) <- c("renyiaccum", class(result))
     result

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2013-11-08 10:40:12 UTC (rev 2678)
+++ pkg/vegan/inst/ChangeLog	2013-11-08 13:22:06 UTC (rev 2679)
@@ -23,7 +23,11 @@
 	how(). 
 
 	* renyiaccum: plot() works also when only one index ('scales') was
-	used.
+	used. The function gained new argument 'collector = FALSE' to
+	accumulate sites in the order they are in the data set in addition
+	to the summary statistics of permutations. This can be used to
+	analyse the randomness of the particular order of sites (looks
+	like my student would need this).
 	
 Version 2.1-37 (closed November 5, 2013)
 

Modified: pkg/vegan/man/renyi.Rd
===================================================================
--- pkg/vegan/man/renyi.Rd	2013-11-08 10:40:12 UTC (rev 2678)
+++ pkg/vegan/man/renyi.Rd	2013-11-08 13:22:06 UTC (rev 2679)
@@ -18,8 +18,9 @@
    hill = FALSE)
 \method{plot}{renyi}(x, ...)
 renyiaccum(x, scales = c(0, 0.5, 1, 2, 4, Inf), permutations = 100, 
-    raw = FALSE, subset, ...)
-\method{plot}{renyiaccum}(x, what = c("mean", "Qnt 0.025", "Qnt 0.975"), type = "l", 
+    raw = FALSE, collector = FALSE, subset, ...)
+\method{plot}{renyiaccum}(x, what = c("Collector", "mean", "Qnt 0.025", "Qnt 0.975"),
+    type = "l", 
     ...)
 \method{persp}{renyiaccum}(x, theta = 220, col = heat.colors(100), zlim, ...)
 rgl.renyiaccum(x, rgl.height = 0.2, ...)
@@ -34,6 +35,10 @@
   \item{raw}{if \code{FALSE} then return summary statistics of
     permutations, and if \code{TRUE} then returns the individual
     permutations.}
+  \item{collector}{Accumulate the diversities in the order the sites are
+    in the data set, and the collector curve can be plotted against
+    summary of permutations. The argument is ignored if \code{raw = TRUE}.
+  }
   \item{subset}{logical expression indicating sites (rows) to keep: missing
     values are taken as \code{FALSE}.}
   \item{what}{Items to be plotted.}



More information about the Vegan-commits mailing list