[Vegan-commits] r772 - in branches/1.15: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Mar 31 18:33:49 CEST 2009
Author: jarioksa
Date: 2009-03-31 18:33:49 +0200 (Tue, 31 Mar 2009)
New Revision: 772
Modified:
branches/1.15/R/ordisurf.R
branches/1.15/inst/ChangeLog
branches/1.15/man/ordisurf.Rd
Log:
updated ordisurf in branches/1.15: grid item and 'bubble' argument
Modified: branches/1.15/R/ordisurf.R
===================================================================
--- branches/1.15/R/ordisurf.R 2009-03-30 18:29:17 UTC (rev 771)
+++ branches/1.15/R/ordisurf.R 2009-03-31 16:33:49 UTC (rev 772)
@@ -1,7 +1,8 @@
"ordisurf" <-
function (x, y, choices = c(1, 2), knots = 10, family = "gaussian",
col = "red", thinplate = TRUE, add = FALSE, display = "sites",
- w = weights(x), main, nlevels = 10, levels, labcex = 0.6, ...)
+ w = weights(x), main, nlevels = 10, levels, labcex = 0.6,
+ bubble = FALSE, cex = 1, ...)
{
weights.default <- function(object, ...) NULL
GRID = 25
@@ -32,7 +33,12 @@
inpoly = as.integer(inpoly), PACKAGE="vegan")$inpoly
is.na(fit) <- inpoly == 0
if (!add) {
- plot(X, asp = 1, ...)
+ if (bubble) {
+ if (is.numeric(bubble))
+ cex <- bubble
+ cex <- (y - min(y))/diff(range(y)) * (cex-0.4) + 0.4
+ }
+ plot(X, asp = 1, cex = cex, ...)
}
if (!missing(main) || (missing(main) && !add)) {
if (missing(main))
@@ -45,5 +51,7 @@
contour(xn1, xn2, matrix(fit, nrow=GRID), col = col, add = TRUE,
levels = levels, labcex = labcex,
drawlabels = !is.null(labcex) && labcex > 0)
+ mod$grid <- list(x = xn1, y = xn2, z = matrix(fit, nrow = GRID))
+ class(mod) <- c("ordisurf", class(mod))
return(mod)
}
Modified: branches/1.15/inst/ChangeLog
===================================================================
--- branches/1.15/inst/ChangeLog 2009-03-30 18:29:17 UTC (rev 771)
+++ branches/1.15/inst/ChangeLog 2009-03-31 16:33:49 UTC (rev 772)
@@ -5,6 +5,9 @@
Version 1.15-2 (opened January 14, 2009)
+ * merged rev532, 596 to ordisurf: returns a grid item of fitted
+ surface, and gains option for bubble plots of observed values.
+
* merged new beals code by Miquel de Caceres (rev 528:531).
* copied dispindmorisita at rev769 from pkg/vegan.
Modified: branches/1.15/man/ordisurf.Rd
===================================================================
--- branches/1.15/man/ordisurf.Rd 2009-03-30 18:29:17 UTC (rev 771)
+++ branches/1.15/man/ordisurf.Rd 2009-03-31 16:33:49 UTC (rev 772)
@@ -9,7 +9,8 @@
\usage{
ordisurf(x, y, choices=c(1, 2), knots=10, family="gaussian", col="red",
thinplate = TRUE, add = FALSE, display = "sites",
- w = weights(x), main, nlevels = 10, levels, labcex = 0.6, ...)
+ w = weights(x), main, nlevels = 10, levels, labcex = 0.6,
+ bubble = FALSE, cex = 1, ...)
}
\arguments{
@@ -34,13 +35,20 @@
\code{nlevels} if \code{levels} are not supplied.}
\item{labcex}{Label size in contours. Setting this zero will suppress
labels.}
+ \item{bubble}{Use \dQuote{bubble plot} for points, or vary the point
+ diameter by the value of the plotted variable. If \code{bubble} is
+ numeric, its value is used for the maximum symbol size (as in
+ \code{cex}), or if \code{bubble = TRUE}, the value of \code{cex} gives
+ the maximum. The minimum size will always be \code{cex = 0.4}. The
+ option only has an effect if \code{add = FALSE}.}
+ \item{cex}{Character expansion of plotting symbols.}
\item{\dots}{ Other graphical parameters. }
}
\details{
Function \code{ordisurf} fits a smooth surface using thinplate splines
in \code{\link[mgcv]{gam}}, and uses \code{\link[mgcv]{predict.gam}}
to find fitted values in a regular grid.
- Function plots the fitted contours with convex hull of data poitns
+ Function plots the fitted contours with convex hull of data points
either over an existing ordination diagram or draws a new plot
The function uses
\code{\link{scores}} to extract ordination scores, and \code{x} can be
@@ -56,10 +64,21 @@
accordance with constrained \code{\link{cca}}, you should set
\code{display = "lc"} (and possibly \code{scaling = 2}).
}
+
\value{
- Function is usually called for its side effect of drawing the contour
- plot, but it returns the result object of \code{\link[mgcv]{gam}}.
+ Function is usually called for its side effect of drawing the
+ contour plot. The function returns the result object of class
+ \code{"ordisurf"} that inherits from \code{\link[mgcv]{gam}} used
+ internally to fit the surface, but adds an item \code{grid} that
+ contains the data for the grid surface. The item \code{grid} has
+ elements \code{x} and \code{y} which are vectors of axis coordinates,
+ and element \code{z} that is a matrix of fitted values for
+ \code{\link{contour}}. The values outside the convex hull of observed
+ points are \code{NA} in \code{z}. The \code{\link[mgcv]{gam}}
+ component of the result can be used for further analysis like
+ predicting new values (see \code{\link[mgcv]{predict.gam}}).
}
+
\author{ Dave Roberts and Jari Oksanen }
\note{
The default is to use thinplate splines. These make sense in
@@ -78,7 +97,7 @@
library(MASS)
vare.dist <- vegdist(varespec)
vare.mds <- isoMDS(vare.dist)
-with(varechem, ordisurf(vare.mds, Baresoil))
+with(varechem, ordisurf(vare.mds, Baresoil, bubble = 5))
## Cover of Cladina arbuscula
with(varespec, ordisurf(vare.mds, Cla.arb, family=quasipoisson))
}
More information about the Vegan-commits
mailing list