[Dplr-commits] r803 - in pkg/dplR: . R data man vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Apr 10 07:29:13 CEST 2014
Author: andybunn
Date: 2014-04-10 07:29:12 +0200 (Thu, 10 Apr 2014)
New Revision: 803
Modified:
pkg/dplR/ChangeLog
pkg/dplR/NAMESPACE
pkg/dplR/R/chron.R
pkg/dplR/R/crn.plot.R
pkg/dplR/R/read.crn.R
pkg/dplR/TODO
pkg/dplR/data/cana157.rda
pkg/dplR/man/crn.plot.Rd
pkg/dplR/man/read.crn.Rd
pkg/dplR/vignettes/intro-dplR.Rnw
Log:
Added class 'crn' to chron, read.chron, etc. so that plot.crn could be added as an S3 method.
Modified: pkg/dplR/ChangeLog
===================================================================
--- pkg/dplR/ChangeLog 2014-04-09 23:24:28 UTC (rev 802)
+++ pkg/dplR/ChangeLog 2014-04-10 05:29:12 UTC (rev 803)
@@ -9,8 +9,25 @@
- Added chron.plot to export list.
- Added interseries.cor to export list.
- Added plot.rwl as an S3Method.
+- Added plot.crn as an S3Method.
- Added summary.rwl as an S3Method.
+File: crn.plot.R
+-------------------------
+- Added several new plotting options to give users more control of plot
+- Aliased crn.plot to plot.crn so it can be used as an S3 plot method.
+ Thus a user can now to bar <- chon(foo); plot(bar)
+- Help revised considerably
+
+
+File: read.crn.R
+-------------------------
+- Added class "crn" to output object.
+
+File: cana157.rda
+-------------------------
+- Added class "crn" to object.
+
File: detrend.R and detrend.series.R
------------
- Added an Ar detrend method. Revised plotting in detrend.series
@@ -93,15 +110,6 @@
-------------------------
- Cosmetic changes to plot.
-File: crn.plot.R
--------------------------
-- Added several new plotting options to give users more control of plot
-- Aliased crn.plot to chron.plot to be consistent with the chron() function.
- It was confusing to use bar <- chon(foo) but not be able to use
- chron.plot(bar). It would be nice to make chron an S3method to thus be
- able to just do plot(bar) I suppose.
-- Help revised considerably
-
File: rwi.stats.running.R
-------------------------
Modified: pkg/dplR/NAMESPACE
===================================================================
--- pkg/dplR/NAMESPACE 2014-04-09 23:24:28 UTC (rev 802)
+++ pkg/dplR/NAMESPACE 2014-04-10 05:29:12 UTC (rev 803)
@@ -36,8 +36,10 @@
series.rwl.plot, skel.plot, spag.plot, strip.rwl, tbrm,
tridas.vocabulary, uuid.gen, wavelet.plot, wc.to.po,
write.compact, write.crn, write.rwl, write.tridas,
- write.tucson, chron.plot, plot.rwl, interseries.cor, summary.rwl)
+ write.tucson, plot.rwl, interseries.cor, summary.rwl,
+ plot.crn)
S3method(print, redfit)
S3method(plot, rwl)
+S3method(plot, crn)
S3method(summary, rwl)
\ No newline at end of file
Modified: pkg/dplR/R/chron.R
===================================================================
--- pkg/dplR/R/chron.R 2014-04-09 23:24:28 UTC (rev 802)
+++ pkg/dplR/R/chron.R 2014-04-10 05:29:12 UTC (rev 803)
@@ -28,5 +28,6 @@
names(out) <- c(paste0(prefix.str, "std"), "samp.depth")
}
row.names(out) <- row.names(x)
+ class(out) <- c("crn", "data.frame")
out
}
Modified: pkg/dplR/R/crn.plot.R
===================================================================
--- pkg/dplR/R/crn.plot.R 2014-04-09 23:24:28 UTC (rev 802)
+++ pkg/dplR/R/crn.plot.R 2014-04-10 05:29:12 UTC (rev 803)
@@ -1,4 +1,6 @@
-`chron.plot` <- `crn.plot` <- function(crn, add.spline=FALSE, nyrs=NULL, f=0.5,
+`plot.crn` <- function(x, ...){ crn.plot(x, ...) }
+
+`crn.plot` <- function(x, add.spline=FALSE, nyrs=NULL, f=0.5,
crn.line.col='grey50',
spline.line.col='red',
samp.depth.col='grey90',
@@ -6,7 +8,8 @@
crn.lwd=1, spline.lwd=1.5,
abline.pos=1, abline.col='black',
abline.lty=1, abline.lwd=1,
- xlab='Year', ylab='RWI') {
+ ...) {
+ crn <- x
if(!is.data.frame(crn)) stop("'crn' must be a data.frame")
op <- par(no.readonly=TRUE) # Save par
@@ -32,7 +35,7 @@
for(i in seq_len(nCrn)){
spl <- crn[[i]]
plot(yr.vec, spl, type="n",axes=FALSE,
- xlab=xlab, ylab=ylab, main=crn.names[i])
+ main=crn.names[i],...)
if(sd.exist) {
par(new=TRUE)
plot(yr.vec, samp.depth, type="n",
@@ -44,7 +47,7 @@
mtext(text.samp, side=4, line=1.25)
}
par(new=TRUE)
- plot(yr.vec, spl, type="n",axes=FALSE,xlab='',ylab='')
+ plot(yr.vec, spl, type="n",axes=FALSE,xlab="",ylab="")
abline(h=abline.pos,lwd=abline.lwd,
lty=abline.lty,col=abline.col)
lines(yr.vec, spl, col=crn.line.col,lwd=crn.lwd)
Modified: pkg/dplR/R/read.crn.R
===================================================================
--- pkg/dplR/R/read.crn.R 2014-04-09 23:24:28 UTC (rev 802)
+++ pkg/dplR/R/read.crn.R 2014-04-10 05:29:12 UTC (rev 803)
@@ -137,5 +137,6 @@
crn.mat[, seq.series] <- crn.mat[, seq.series] / 1000
crn.df <- as.data.frame(crn.mat)
}
+ class(crn.df) <- c("crn", "data.frame")
crn.df
}
Modified: pkg/dplR/TODO
===================================================================
--- pkg/dplR/TODO 2014-04-09 23:24:28 UTC (rev 802)
+++ pkg/dplR/TODO 2014-04-10 05:29:12 UTC (rev 803)
@@ -8,10 +8,8 @@
* Decide when to use class('rwl') in functions dealing with rwl objects.
Other than the plot and summary S3Method for rwl, are there cases when
- having that class would be useful. E.g., in error checking?
+ having that class would be useful. E.g., in error checking? Same for
+ class('crn'). There is a plot method now. What else?
-- Consider the benefits and drawbacks of creating classes for chonologies.
- One benefit would be an S3 plot method for chronologies.
+- Related: Consider the benefits and drawbacks of creating classes for rwi.
-- Consider the benefits and drawbacks of creating classes for rwi.
-
Modified: pkg/dplR/data/cana157.rda
===================================================================
(Binary files differ)
Modified: pkg/dplR/man/crn.plot.Rd
===================================================================
--- pkg/dplR/man/crn.plot.Rd 2014-04-09 23:24:28 UTC (rev 802)
+++ pkg/dplR/man/crn.plot.Rd 2014-04-10 05:29:12 UTC (rev 803)
@@ -1,34 +1,27 @@
\name{crn.plot}
+\alias{plot.crn}
\alias{crn.plot}
-\alias{chron.plot}
\title{ Plot a Tree-Ring Chronology }
\description{
This function makes a default plot of a tree-ring chronology from a
\code{data.frame} of the type produced by \code{\link{chron}}.
}
\usage{
-chron.plot(crn, add.spline = FALSE, nyrs = NULL, f = 0.5,
- crn.line.col='grey50',spline.line.col='red',
- samp.depth.col='grey90',
- samp.depth.border.col='grey80',
- crn.lwd=1,spline.lwd=1.5,
- abline.pos=1,abline.col='black',
- abline.lty=1,abline.lwd=1,
- xlab='Year',ylab='RWI')
-
-crn.plot(crn, add.spline = FALSE, nyrs = NULL, f = 0.5,
+crn.plot(x, add.spline = FALSE, nyrs = NULL, f = 0.5,
crn.line.col='grey50',spline.line.col='red',
samp.depth.col='grey90',
samp.depth.border.col='grey80',
crn.lwd=1,spline.lwd=1.5,
abline.pos=1,abline.col='black',
- abline.lty=1,abline.lwd=1,
- xlab='Year',ylab='RWI')
+ abline.lty=1,abline.lwd=1,...)
+
+\method{plot}{crn}(x, ...)
+
}
\arguments{
- \item{crn}{ a \code{data.frame} as produced by
+ \item{x}{ a \code{data.frame} as produced by
\code{\link{chron}}. The \code{data.frame} should have the years in
- \code{rownames(\var{crn})}, the chronologies in the columns.
+ \code{rownames(\var{x})}, the chronologies in the columns.
Optionally, the last column can contain the sample depth named
\code{"samp.depth"}. }
\item{add.spline}{ a \code{logical} flag. Will add a line with a
@@ -38,20 +31,20 @@
\code{\var{nyrs}} is \code{NULL}. }
\item{f}{ a number between 0 and 1 giving the frequency response or
wavelength cutoff. Defaults to 0.5. }
- \item{crn.line.col}{ color for the crn line }
+ \item{crn.line.col}{ color for the x line }
\item{spline.line.col}{ color for the spline (if added) }
\item{samp.depth.col}{ color for the sample depth polygon (if present) }
\item{samp.depth.border.col}{ border color for the sample depth
polygon (if present)}
- \item{crn.lwd}{ line width for the crn line}
+ \item{crn.lwd}{ line width for the x line}
\item{spline.lwd}{ line width for the spline (if added) }
\item{abline.pos}{ position for a refernce abline on the y-axis.
No line added if NULL }
\item{abline.col}{ color for the reference abline (if added) }
\item{abline.lty}{ line type the reference abline (if added) }
\item{abline.lwd}{ line width for the reference abline (if added)}
- \item{xlab}{ label for x-axis }
- \item{ylab}{ label for y-axis }
+ \item{\dots}{ Additional arguments from the generic function to pass to
+ \code{\link{plot}}. }
}
\details{
This makes a simple plot of one or more tree-ring chronologies.
@@ -63,14 +56,14 @@
\seealso{ \code{\link{chron}}
}
\examples{data(cana157)
-crn.plot(cana157)
-chron.plot(cana157)
+crn.plot(cana157,xlab='Year',ylab='RWI')
+plot(cana157,xlab='Year',ylab='RWI')
# with added spline
-chron.plot(cana157,add.spline=TRUE, nyrs=32)
+crn.plot(cana157,add.spline=TRUE, nyrs=32, xlab='Year',ylab='RWI')
## Without sample depth
cana157.mod <- cana157
cana157.mod$samp.depth <- NULL
-crn.plot(cana157.mod, add.spline = TRUE)
+crn.plot(cana157.mod, add.spline = TRUE, xlab='Year',ylab='RWI')
## With multiple chronologies
data(gp.rwl)
data(gp.po)
@@ -80,7 +73,7 @@
\dontrun{
# not pretty - but illustrates the coloring options
my.cols <- c("#3182BD","#9ECAE1","#DEEBF7","#31A354","#A1D99B","#E5F5E0")
- chron.plot(cana157,add.spline=TRUE,nyrs=32,
+ crn.plot(cana157,add.spline=TRUE,nyrs=32,
crn.line.col=my.cols[5],
spline.line.col=my.cols[4],
samp.depth.col=my.cols[3],
@@ -91,7 +84,7 @@
# a raw ring-width chronology
data(ca533)
ca533.raw.crn <- chron(ca533, prefix = "CAM")
- chron.plot(ca533.raw.crn,abline.pos=NULL,ylab='mm')
+ crn.plot(ca533.raw.crn,abline.pos=NULL,ylab='mm')
}
}
\keyword{ hplot }
Modified: pkg/dplR/man/read.crn.Rd
===================================================================
--- pkg/dplR/man/read.crn.Rd 2014-04-09 23:24:28 UTC (rev 802)
+++ pkg/dplR/man/read.crn.Rd 2014-04-10 05:29:12 UTC (rev 803)
@@ -33,7 +33,8 @@
A \code{data.frame} with each chronology in columns and the years as
rows. The chronology \acronym{ID}s are the column names and the years
are the row names. If the file includes sample depth that is included
- as the last column (\code{\var{samp.depth}}).
+ as the last column (\code{\var{samp.depth}}). The output class is
+ class "crn" and "data.frame"
}
\author{ Andy Bunn. Patched and improved by Mikko Korpela. }
\keyword{ IO }
Modified: pkg/dplR/vignettes/intro-dplR.Rnw
===================================================================
--- pkg/dplR/vignettes/intro-dplR.Rnw 2014-04-09 23:24:28 UTC (rev 802)
+++ pkg/dplR/vignettes/intro-dplR.Rnw 2014-04-10 05:29:12 UTC (rev 803)
@@ -270,17 +270,17 @@
dim(ca533.crn)
@
-The chronology can be plotted using the \code{chron.plot} function which
+The chronology can be plotted using the \code{crn.plot} function which
has many arguments for customization. Here we'll just make a simple plot of the
chronology with a smoothing spline added.
<<c, fig=TRUE>>=
-chron.plot(ca533.crn, add.spline=TRUE, nyrs=20)
+crn.plot(ca533.crn, add.spline=TRUE, nyrs=20)
@
\begin{figure}
\centering
\includegraphics{intro-dplR-c}
\caption{Campito Mountain chronology with 20-year smoothing spline.}
-\label{fig:chron.plot.spline}
+\label{fig:crn.plot.spline}
\end{figure}
In general this vignette aims to give a very cursory overview of basic tasks
@@ -338,7 +338,7 @@
\centering
\includegraphics{intro-dplR-d}
\caption{Campito Mountain chronology using an EPS cutoff.}
-\label{fig:chron.plot.eps}
+\label{fig:crn.plot.eps}
\end{figure}
\section{Prospectus}
More information about the Dplr-commits
mailing list