[Analogue-commits] r260 - in pkg: . R inst man tests/Examples
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Apr 5 23:48:31 CEST 2012
Author: gsimpson
Date: 2012-04-05 23:48:31 +0200 (Thu, 05 Apr 2012)
New Revision: 260
Added:
pkg/R/caterpillarPlot.R
pkg/man/caterpillarPlot.Rd
Modified:
pkg/DESCRIPTION
pkg/NAMESPACE
pkg/inst/ChangeLog
pkg/tests/Examples/analogue-Ex.Rout.save
Log:
add caterpillarPlot and bump to 0.9-0
Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION 2012-04-03 20:07:27 UTC (rev 259)
+++ pkg/DESCRIPTION 2012-04-05 21:48:31 UTC (rev 260)
@@ -1,7 +1,7 @@
Package: analogue
Type: Package
Title: Analogue and weighted averaging methods for palaeoecology
-Version: 0.8-2
+Version: 0.9-0
Date: $Date$
Depends: R (>= 2.15.0), stats, graphics, vegan (>= 1.17-12), lattice, grid,
MASS, princurve
Modified: pkg/NAMESPACE
===================================================================
--- pkg/NAMESPACE 2012-04-03 20:07:27 UTC (rev 259)
+++ pkg/NAMESPACE 2012-04-05 21:48:31 UTC (rev 260)
@@ -17,13 +17,46 @@
import(graphics)
## Exports
-export(analog, bayesF, bootstrap, chooseTaxa, cma, crossval, deshrink, dissim,
- dissimilarities, distance, fuse, getK, gradientDist, join, logitreg,
- mat, mcarlo, minDC, optima, panel.Loess, panel.Stratiplot, pcr,
- performance, prcurve, ##randomWA,
- reconPlot, residLen, RMSEP, roc,
- smoothSpline, Stratiplot, stdError, timetrack, tran, varExpl, wa,
- weightedCor, "setK<-", Hellinger, ChiSquare)
+export(analog,
+ bayesF,
+ bootstrap,
+ caterpillarPlot,
+ chooseTaxa,
+ cma,
+ crossval,
+ deshrink,
+ dissim,
+ dissimilarities,
+ distance,
+ fuse,
+ getK,
+ gradientDist,
+ join,
+ logitreg,
+ mat,
+ mcarlo,
+ minDC,
+ optima,
+ panel.Loess,
+ panel.Stratiplot,
+ pcr,
+ performance,
+ prcurve, ##randomWA,
+ reconPlot,
+ residLen,
+ RMSEP,
+ roc,
+ smoothSpline,
+ Stratiplot,
+ stdError,
+ timetrack,
+ tran,
+ varExpl,
+ wa,
+ weightedCor,
+ "setK<-",
+ Hellinger,
+ ChiSquare)
### S3 Methods
##
Added: pkg/R/caterpillarPlot.R
===================================================================
--- pkg/R/caterpillarPlot.R (rev 0)
+++ pkg/R/caterpillarPlot.R 2012-04-05 21:48:31 UTC (rev 260)
@@ -0,0 +1,52 @@
+`caterpillarPlot` <- function(x, env, useN2 = TRUE, decreasing = TRUE,
+ mult = 1, labels, xlab = NULL,
+ pch = 21, bg = "white", col = "black", lcol = col,
+ ...) {
+ ## compute the optima
+ opt <- optima(x = x, env = env)
+ ## and tolerances
+ tol <- tolerance(x = x, env = env, useN2 = useN2)
+
+ ## reorder
+ ord <- order(opt, decreasing = decreasing)
+ opt <- opt[ord]
+ tol <- tol[ord]
+
+ ## par
+ op <- par(yaxs = "i")
+ on.exit(par(op))
+
+ ## number of species
+ nspp <- ncol(x)
+ yvals <- seq_len(nspp)
+
+ ## labels == spp names
+ if(missing(labels)) {
+ labels <- names(opt)
+ }
+ linch <- if (!is.null(labels))
+ max(strwidth(labels, "inch"), na.rm = TRUE)
+ nmai <- par("mai")
+ nmai[2L] <- nmai[4L] + linch + 0.1
+ par(mai = nmai)
+
+ ## ylab
+ if(is.null(xlab))
+ xlab <- deparse(substitute(env))
+
+ ## tolerance range
+ upr <- opt + (tol * mult)
+ lwr <- opt - (tol * mult)
+
+ ## do the plot
+ plot(c(lwr, upr), rep.int(yvals, 2), type = "n", axes = FALSE,
+ ylab = "", xlab = xlab, ylim = range(0, yvals + 1), ...)
+ abline(h = yvals, lty = 1, lwd = 0.5, col = "lightgray")
+ segments(lwr, yvals, upr, yvals, col = lcol, ...)
+ points(opt, yvals, pch = pch, bg = bg, col = col, ...)
+ axis(side = 1, ...)
+ axis(side = 2, labels = labels, at = yvals, las = 1, ...)
+ box()
+ out <- data.frame(Optima = opt, Tolerance = tol)
+ invisible(out)
+}
Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog 2012-04-03 20:07:27 UTC (rev 259)
+++ pkg/inst/ChangeLog 2012-04-05 21:48:31 UTC (rev 260)
@@ -1,5 +1,10 @@
analogue Change Log
+Version 0.9-0
+
+ * caterpillarPlot: new function that draws a caterpillar plot
+ of species WA optima and tolerances.
+
Version 0.8-2
* Dependencies: analogue now requires R >= 2.15.0
Added: pkg/man/caterpillarPlot.Rd
===================================================================
--- pkg/man/caterpillarPlot.Rd (rev 0)
+++ pkg/man/caterpillarPlot.Rd 2012-04-05 21:48:31 UTC (rev 260)
@@ -0,0 +1,81 @@
+\name{caterpillarPlot}
+\alias{caterpillarPlot}
+
+\title{
+ Caterpillar plot of species' WA optima and tolerance range.
+}
+
+\description{
+ Draws a caterpillar plot of the weighted average optima and tolerance
+ range for each of the species in a data set.
+}
+
+\usage{
+caterpillarPlot(x, env, useN2 = TRUE, decreasing = TRUE, mult = 1,
+ labels, xlab = NULL, pch = 21, bg = "white",
+ col = "black", lcol = col, ...)
+}
+
+
+\arguments{
+ \item{x}{Species data matrix or data frame.}
+ \item{env}{numeric; variable for which optima and tolerances are
+ required.}
+ \item{useN2}{logical; should Hill's N2 values be used to produce
+ un-biased tolerances?}
+ \item{decreasing}{logical; should the sort order of the species be
+ increasing or decreasing?}
+ \item{mult}{numeric; multiplication factor for species' tolerances.}
+ \item{labels}{character; vector of labels for the species names with
+ which to annotate the y-axis. If missing, \code{names(x)} is used.}
+ \item{xlab}{character; the x-axis label. If \code{NULL}, the default,
+ a description of \code{env} is used.}
+ \item{pch, bg, col}{The plotting character to use and its background and
+ foreground colour. See \code{\link{par}}.}
+ \item{lcol}{The colour to use for the tolerance range.}
+ \item{\dots}{Additional graphical arguments to be passed on to
+ plotting functions.}
+}
+
+%\details{
+%% ~~ If necessary, more details than the description above ~~
+%}
+
+\value{
+ The function results in a plot on the currently active device. A data
+ frame with components \code{Optima} and \code{Tolerance} is returned
+ invisibly.
+}
+
+%\references{}
+
+\author{
+ Gavin L. Simpson
+}
+
+%\note{}
+
+\seealso{
+ For the underlying computations \code{\link{optima}} and
+ \code{\link{tolerance}}.
+}
+
+\examples{
+data(ImbrieKipp)
+data(SumSST)
+
+## default plot
+caterpillarPlot(ImbrieKipp, SumSST)
+
+## customisation
+opttol <-
+ caterpillarPlot(ImbrieKipp, SumSST, col = "red2", bg = "yellow",
+ xlab = expression(Summer~Sea~Surface~Temperature~(degree*C)))
+
+## invisibly returns the optima and tolerances
+head(opttol)
+}
+
+% Add one or more standard keywords, see file 'KEYWORDS' in the
+% R documentation directory.
+\keyword{ hplot }
Modified: pkg/tests/Examples/analogue-Ex.Rout.save
===================================================================
--- pkg/tests/Examples/analogue-Ex.Rout.save 2012-04-03 20:07:27 UTC (rev 259)
+++ pkg/tests/Examples/analogue-Ex.Rout.save 2012-04-05 21:48:31 UTC (rev 260)
@@ -1,5 +1,5 @@
-R version 2.14.1 Patched (2012-01-10 r58088)
+R version 2.15.0 Patched (2012-03-30 r58877)
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-unknown-linux-gnu (64-bit)
@@ -24,12 +24,12 @@
> library('analogue')
Loading required package: vegan
Loading required package: permute
-This is vegan 2.0-1
+This is vegan 2.0-3
Loading required package: lattice
Loading required package: grid
Loading required package: MASS
Loading required package: princurve
-This is analogue 0.8-1
+This is analogue 0.9-0
>
> assign(".oldSearch", search(), pos = 'CheckExEnv')
> cleanEx()
@@ -1139,6 +1139,42 @@
>
>
> cleanEx()
+> nameEx("caterpillarPlot")
+> ### * caterpillarPlot
+>
+> flush(stderr()); flush(stdout())
+>
+> ### Name: caterpillarPlot
+> ### Title: Caterpillar plot of species' WA optima and tolerance range.
+> ### Aliases: caterpillarPlot
+> ### Keywords: hplot
+>
+> ### ** Examples
+>
+> data(ImbrieKipp)
+> data(SumSST)
+>
+> ## default plot
+> caterpillarPlot(ImbrieKipp, SumSST)
+>
+> ## customisation
+> opttol <-
++ caterpillarPlot(ImbrieKipp, SumSST, col = "red2", bg = "yellow",
++ xlab = expression(Summer~Sea~Surface~Temperature~(degree*C)))
+>
+> ## invisibly returns the optima and tolerances
+> head(opttol)
+ Optima Tolerance
+P.obliq 26.94320 1.554762
+G.duter 26.49014 1.998304
+C.nitid 26.41005 1.461725
+G.rubes 26.27479 1.968294
+G.saccu 26.18001 1.979651
+G.mentu 26.13778 2.386584
+>
+>
+>
+> cleanEx()
> nameEx("chooseTaxa")
> ### * chooseTaxa
>
@@ -7017,7 +7053,7 @@
> ### * <FOOTER>
> ###
> cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n")
-Time elapsed: 23.044 1.291 24.51 0 0
+Time elapsed: 15.815 0.248 16.505 0 0
> grDevices::dev.off()
null device
1
More information about the Analogue-commits
mailing list