[Vegan-commits] r941 - in branches/1.15: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Aug 23 08:25:18 CEST 2009


Author: jarioksa
Date: 2009-08-23 08:25:16 +0200 (Sun, 23 Aug 2009)
New Revision: 941

Added:
   branches/1.15/R/radlattice.R
Modified:
   branches/1.15/inst/ChangeLog
   branches/1.15/man/radfit.Rd
Log:
copied radlattice.R to branches (r551, 553)

Copied: branches/1.15/R/radlattice.R (from rev 940, pkg/vegan/R/radlattice.R)
===================================================================
--- branches/1.15/R/radlattice.R	                        (rev 0)
+++ branches/1.15/R/radlattice.R	2009-08-23 06:25:16 UTC (rev 941)
@@ -0,0 +1,29 @@
+`radlattice` <-
+    function(x, BIC = FALSE, ...)
+{
+    require(lattice) || stop("requires package 'lattice'")
+    y <- x$y
+    fv <- unlist(fitted(x))
+    mods <- names(x$models)
+    p <- length(mods)
+    n <- length(y)
+    Abundance <- rep(y, p)
+    Rank <- rep(1:n, p)
+    Model <- factor(rep(mods, each=n), levels = mods)
+    aic <- AIC(x, BIC = BIC)
+    col <- trellis.par.get("superpose.line")$col
+    if (length(col) > 1)
+        col <- col[2]
+    xyplot(Abundance ~  Rank | Model, subscripts = TRUE,
+           scales = list(y = list(log = 2)), as.table = TRUE,
+           panel = function(x, y, subscripts) {
+               panel.xyplot(x, y, ...)
+               panel.xyplot(x, log2(fv[subscripts]), type="l", lwd=3,
+                            col = col, ...)
+               panel.text(max(x), max(y), paste(if (BIC) "BIC" else "AIC", "=",
+                          formatC(aic[panel.number()], digits=2, format="f")),
+                          pos=2)
+           }
+           )
+}
+

Modified: branches/1.15/inst/ChangeLog
===================================================================
--- branches/1.15/inst/ChangeLog	2009-08-23 05:56:18 UTC (rev 940)
+++ branches/1.15/inst/ChangeLog	2009-08-23 06:25:16 UTC (rev 941)
@@ -39,6 +39,8 @@
 
 	* panel.ordi has now 'arrows': merged r813, 814, 835, 879.
 
+	* radlattice copied from pkg/ and merged doc changes r551, 553.
+
 Version 1.15-3 (released June 17, 2009)
 
 	* merged revs 866 to 868: changed the way capscale displays

Modified: branches/1.15/man/radfit.Rd
===================================================================
--- branches/1.15/man/radfit.Rd	2009-08-23 05:56:18 UTC (rev 940)
+++ branches/1.15/man/radfit.Rd	2009-08-23 06:25:16 UTC (rev 941)
@@ -11,6 +11,7 @@
 \alias{plot.radfit}
 \alias{plot.radline}
 \alias{plot.rad}
+\alias{radlattice}
 \alias{points.radline}
 \alias{print.radfit.frame}
 \alias{print.radfit}
@@ -34,6 +35,7 @@
      as.table = TRUE, ...)
 \method{radfit}{default}(x, ...)
 \method{plot}{radfit}(x, BIC = FALSE, legend = TRUE, ...)  
+radlattice(x, BIC = FALSE, ...)
 rad.null(x, family=poisson, ...)
 rad.preempt(x, family = poisson, ...)
 rad.lognormal(x, family = poisson, ...)
@@ -90,14 +92,17 @@
   single community or a data frame where each row represents a
   distinct community.  All these functions have their own \code{plot}
   functions. When the argument is a data frame, \code{plot} uses
-  \code{\link[lattice]{Lattice}} graphics, and other functions use
+  \code{\link[lattice]{Lattice}} graphics, and other \code{plot} functions use
   ordinary graphics. The ordinary graphics functions return invisibly an
   \code{\link{ordiplot}} object for observed points, and function
   \code{\link{identify.ordiplot}} can be used to label selected
   species. The most complete control of graphics can be achieved
   with \code{rad.XXXX} methods which have \code{points} and \code{lines}
   functions to add observed values and fitted models into existing
-  graphs.  
+  graphs.  Alternatively, \code{radlattice} uses
+  \code{\link[lattice]{Lattice}} graphics to display each
+  \code{radfit} model in a separate panel together with their AIC or
+  BIC values.
 
   Function \code{rad.null} fits a brokenstick model where the expected
   abundance of species at rank \eqn{r} is \eqn{a_r = (J/S) \sum_{x=r}^S
@@ -223,10 +228,13 @@
 mod
 plot(mod)
 mod <- radfit(BCI[1,])
+## Standard plot overlaid for all models
 ## Pre-emption model is a line
 plot(mod)
 ## log for both axes: Zipf model is a line
 plot(mod, log = "xy")
+## Lattice graphics separately for each model
+radlattice(mod)
 # Take a subset of BCI to save time and nerves
 mod <- radfit(BCI[2:5,])
 mod



More information about the Vegan-commits mailing list