[Vegan-commits] r551 - in pkg: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Nov 9 08:12:32 CET 2008
Author: jarioksa
Date: 2008-11-09 08:12:32 +0100 (Sun, 09 Nov 2008)
New Revision: 551
Added:
pkg/R/radlattice.R
Modified:
pkg/inst/ChangeLog
pkg/man/radfit.Rd
Log:
radlattice: lattice graphics for radfit results
Added: pkg/R/radlattice.R
===================================================================
--- pkg/R/radlattice.R (rev 0)
+++ pkg/R/radlattice.R 2008-11-09 07:12:32 UTC (rev 551)
@@ -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: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog 2008-11-07 19:55:59 UTC (rev 550)
+++ pkg/inst/ChangeLog 2008-11-09 07:12:32 UTC (rev 551)
@@ -4,9 +4,14 @@
Version 1.16-4 (opened November 1, 2008)
+ * radlattice: a new function to display each radfit model in a
+ separate panel together with their AIC or BIC values. I wanter to
+ have this for a manuscript.
+
* plot.cca: takes care that plotted items have non-NULL names that
plot neatly. This was already take care of with formula
- interface, but now it should work also in other cases in plots.
+ interface, but now it should work also in other cases in
+ plots. Reported by Daniel Borcard.
* permatwsap: quasiswap method is implemented for count data based
on the idea of Carsten Dormann in the swap.web::bipartite
Modified: pkg/man/radfit.Rd
===================================================================
--- pkg/man/radfit.Rd 2008-11-07 19:55:59 UTC (rev 550)
+++ pkg/man/radfit.Rd 2008-11-09 07:12:32 UTC (rev 551)
@@ -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, ...)
@@ -85,14 +87,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
More information about the Vegan-commits
mailing list