[Vegan-commits] r1945 - in pkg/vegan: . R man tests/Examples

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Oct 10 19:37:36 CEST 2011


Author: jarioksa
Date: 2011-10-10 19:37:35 +0200 (Mon, 10 Oct 2011)
New Revision: 1945

Added:
   pkg/vegan/R/plot.preston.R
Modified:
   pkg/vegan/NAMESPACE
   pkg/vegan/man/fisherfit.Rd
   pkg/vegan/tests/Examples/vegan-Ex.Rout.save
Log:
add plot & lines for as.preston and as.fisher

Modified: pkg/vegan/NAMESPACE
===================================================================
--- pkg/vegan/NAMESPACE	2011-10-10 13:43:09 UTC (rev 1944)
+++ pkg/vegan/NAMESPACE	2011-10-10 17:37:35 UTC (rev 1945)
@@ -174,6 +174,7 @@
 # lines: graphics
 S3method(lines, humpfit)
 S3method(lines, permat)
+S3method(lines, preston)
 S3method(lines, prestonfit)
 S3method(lines, procrustes)
 S3method(lines, radline)
@@ -215,6 +216,7 @@
 S3method(plot, clamtest)
 S3method(plot, decorana)
 S3method(plot, envfit)
+S3method(plot, fisher)
 S3method(plot, fisherfit)
 S3method(plot, fitspecaccum)
 S3method(plot, humpfit)
@@ -229,6 +231,7 @@
 S3method(plot, permat)
 S3method(plot, poolaccum)
 S3method(plot, prc)
+S3method(plot, preston)
 S3method(plot, prestonfit)
 S3method(plot, procrustes)
 S3method(plot, profile.fisherfit)

Added: pkg/vegan/R/plot.preston.R
===================================================================
--- pkg/vegan/R/plot.preston.R	                        (rev 0)
+++ pkg/vegan/R/plot.preston.R	2011-10-10 17:37:35 UTC (rev 1945)
@@ -0,0 +1,50 @@
+### Similar plotting functions as plot.prestonfit/fisherfit, but only
+### for the data without the fitted models. These can be used with the
+### result of as.preston(), as.fisher().
+
+## as plot.prestonfit, but plots only the bars of as.preston()
+
+`plot.preston` <-
+        function (x, xlab = "Frequency", ylab = "Species", bar.col = "skyblue", 
+                  ...) 
+{
+    freq <- x
+    oct <- as.numeric(names(freq))
+    noct <- max(oct) + 1
+    plot(oct, freq, type = "n", ylim = c(0, max(freq)),
+         xlim = c(-1, max(oct)), ylab = ylab, xlab = xlab, axes = FALSE, ...)
+    axis(2)
+    axis(1, at = 0:noct, labels = 2^(0:noct))
+    box()
+    rect(oct - 1, 0, oct, freq, col = bar.col, ...)
+    invisible()
+}
+
+
+`lines.preston` <-
+    function(x, xadjust = 0.5, ...)
+{
+    oct <- as.numeric(names(x)) - xadjust 
+    lines(oct, x, ...)
+}
+
+## as plot.fisherfit, but plots only the bars of as.fisherfit
+
+`plot.fisher` <-
+    function(x, xlab = "Frequency", ylab = "Species", bar.col = "skyblue",
+             kind = c("bar", "hiplot", "points", "lines"), add = FALSE,
+             ...)
+{
+    kind <- match.arg(kind)
+    freq <- as.numeric(names(x))
+    if (!add)
+        plot(freq, x, ylab=ylab, xlab=xlab,
+             ylim=c(0,max(x)),  xlim=c(0.5, max(freq)+0.5), type="n", ...)
+    switch(kind,
+           "bar" = rect(freq-0.5,0,freq+0.5,x, col=bar.col, ...),
+           "hiplot" = points(freq, x, col =bar.col, type = "h",  ...),
+           "points" = points(freq, x, col =bar.col, ...),
+           "lines" = lines(freq, x, col =bar.col, ...)
+       )
+    invisible()
+}

Modified: pkg/vegan/man/fisherfit.Rd
===================================================================
--- pkg/vegan/man/fisherfit.Rd	2011-10-10 13:43:09 UTC (rev 1944)
+++ pkg/vegan/man/fisherfit.Rd	2011-10-10 17:37:35 UTC (rev 1945)
@@ -10,6 +10,9 @@
 \alias{as.preston}
 \alias{plot.prestonfit}
 \alias{lines.prestonfit}
+\alias{plot.preston}
+\alias{lines.preston}
+\alias{plot.fisher}
 \alias{veiledspec}
 
 \title{Fit Fisher's Logseries and Preston's Lognormal Model to Abundance Data}
@@ -32,7 +35,11 @@
 \method{lines}{prestonfit}(x, line.col = "red", lwd = 2, ...)
 veiledspec(x, ...)
 as.fisher(x, ...)
+\method{plot}{fisher}(x, xlab = "Frequency", ylab = "Species", bar.col = "skyblue",
+             kind = c("bar", "hiplot", "points", "lines"), add = FALSE, ...)
 as.preston(x, tiesplit = TRUE, ...)
+\method{plot}{preston}(x, xlab = "Frequency", ylab = "Species", bar.col = "skyblue", ...)
+\method{lines}{preston}(x, xadjust = 0.5, ...)
 }
 
 \arguments{
@@ -53,6 +60,12 @@
   \item{bar.col}{Colour of data bars.}
   \item{line.col}{Colour of fitted line.}
   \item{lwd}{Width of fitted line.}
+  \item{kind}{Kind of plot to drawn: \code{"bar"} is similar bar plot
+    as in \code{plot.fisherfit}, \code{"hiplot"} draws vertical lines
+    as with \command{plot(..., type="h")}, and \code{"points"} and
+    \code{"lines"} are obvious.}
+  \item{add}{Add to an existing plot.}
+  \item{xadjust}{Adjustment of horizontal positions in octaves.}
   \item{\dots}{Other parameters passed to functions. Ignored in 
     \code{prestonfit} and \code{tiesplit} passed to \code{as.preston} in
     \code{prestondistr}. }
@@ -129,7 +142,7 @@
   the width (sd) of the response. Function \code{as.preston}
   transforms abundance data to octaves.  Argument \code{tiesplit} will
   not influence the fit in \code{prestondistr}, but it will influence
-  the barplot of the octaves.
+  the barplot of the octaves. 
 
   The total extrapolated richness from a fitted Preston model can be
   found with function \code{veiledspec}. The function accepts results

Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save
===================================================================
--- pkg/vegan/tests/Examples/vegan-Ex.Rout.save	2011-10-10 13:43:09 UTC (rev 1944)
+++ pkg/vegan/tests/Examples/vegan-Ex.Rout.save	2011-10-10 17:37:35 UTC (rev 1945)
@@ -161,7 +161,7 @@
 
 Formula:
 y ~ poly(x1, 1) + poly(x2, 1)
-<environment: 0x101f4a668>
+<environment: 0x1019a69f8>
 Total model degrees of freedom 3 
 
 GCV score: 0.0427924
@@ -2607,7 +2607,8 @@
 > ###   Abundance Data
 > ### Aliases: fisherfit as.fisher plot.fisherfit profile.fisherfit
 > ###   confint.fisherfit plot.profile.fisherfit prestonfit prestondistr
-> ###   as.preston plot.prestonfit lines.prestonfit veiledspec
+> ###   as.preston plot.prestonfit lines.prestonfit plot.preston
+> ###   lines.preston plot.fisher veiledspec
 > ### Keywords: univar distribution
 > 
 > ### ** Examples
@@ -4690,7 +4691,7 @@
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x1073aee38>
+<environment: 0x1077de908>
 
 Estimated degrees of freedom:
 6.4351  total = 7.435071 
@@ -4706,7 +4707,7 @@
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x1059c2508>
+<environment: 0x10595d098>
 
 Estimated degrees of freedom:
 6.1039  total = 7.103853 
@@ -4862,7 +4863,7 @@
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x105e9c0a8>
+<environment: 0x106e48ed0>
 
 Estimated degrees of freedom:
 8.9275  total = 9.927492 
@@ -4875,7 +4876,7 @@
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x107753040>
+<environment: 0x107c88140>
 
 Estimated degrees of freedom:
 7.7529  total = 8.75294 
@@ -4888,7 +4889,7 @@
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x10755e548>
+<environment: 0x10779bcd8>
 
 Estimated degrees of freedom:
 8.8962  total = 9.89616 
@@ -7157,7 +7158,7 @@
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x107b81c28>
+<environment: 0x10711bab0>
 
 Estimated degrees of freedom:
 2  total = 3 
@@ -7633,7 +7634,7 @@
 > ### * <FOOTER>
 > ###
 > cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n")
-Time elapsed:  99.046 1.2 101.21 0 0 
+Time elapsed:  101.859 1.444 104.809 0 0 
 > grDevices::dev.off()
 null device 
           1 



More information about the Vegan-commits mailing list