[Dplr-commits] r1030 - in pkg/dplR: . R man vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jun 9 20:28:43 CEST 2016
Author: andybunn
Date: 2016-06-09 20:28:43 +0200 (Thu, 09 Jun 2016)
New Revision: 1030
Added:
pkg/dplR/man/print.rwl.report.Rd
Modified:
pkg/dplR/ChangeLog
pkg/dplR/DESCRIPTION
pkg/dplR/R/rwl.report.R
pkg/dplR/man/rwl.report.Rd
pkg/dplR/vignettes/intro-dplR.Rnw
Log:
More work on rwl.report. Which should probably become report.rwl for consistency.
Modified: pkg/dplR/ChangeLog
===================================================================
--- pkg/dplR/ChangeLog 2016-06-08 23:26:52 UTC (rev 1029)
+++ pkg/dplR/ChangeLog 2016-06-09 18:28:43 UTC (rev 1030)
@@ -22,6 +22,11 @@
- Added rwl.report print method
- Added export from plyr
+File: DESCRIPTION
+-----------------
+
+- Added plyr (>= 1.8.3) to imports
+
File: sea.R
-----------------
Modified: pkg/dplR/DESCRIPTION
===================================================================
--- pkg/dplR/DESCRIPTION 2016-06-08 23:26:52 UTC (rev 1029)
+++ pkg/dplR/DESCRIPTION 2016-06-09 18:28:43 UTC (rev 1030)
@@ -3,7 +3,7 @@
Type: Package
Title: Dendrochronology Program Library in R
Version: 1.6.5
-Date: 2016-03-16
+Date: 2016-06-09
Authors at R: c(person("Andy", "Bunn", role = c("aut", "cph",
"cre", "trl"), email = "andy.bunn at wwu.edu"), person("Mikko",
"Korpela", role = c("aut", "trl")), person("Franco", "Biondi",
@@ -21,7 +21,8 @@
Imports: graphics, grDevices, grid, stats, utils, lattice (>= 0.13-6),
Matrix (>= 1.0-3), digest (>= 0.2.3), gmp (>= 0.5-5),
matrixStats (>= 0.50.0), png (>= 0.1-1), R.utils (>= 1.32.0),
- stringi (>= 0.2-2), stringr (>= 0.4), XML (>= 2.1-0)
+ stringi (>= 0.2-2), stringr (>= 0.4), XML (>= 2.1-0),
+ plyr (>= 1.8.3)
Suggests: Biobase, Cairo (>= 1.5-0), dichromat (>= 1.2-3), foreach,
forecast, iterators, knitr, RColorBrewer, testthat (>= 0.8),
tikzDevice, waveslim
Modified: pkg/dplR/R/rwl.report.R
===================================================================
--- pkg/dplR/R/rwl.report.R 2016-06-08 23:26:52 UTC (rev 1029)
+++ pkg/dplR/R/rwl.report.R 2016-06-09 18:28:43 UTC (rev 1030)
@@ -4,10 +4,14 @@
res <- list()
# get a summary
- res$sum <- summary.rwl(rwl)
-
+ tmp.sum <- summary.rwl(rwl)
+ res$n <- nrow(tmp.sum)
+ res$segbar <- mean(tmp.sum$year)
+ res$yr0 <- min(tmp.sum$first)
+ res$yr1 <- max(tmp.sum$last)
+ res$ar1bar <- mean(tmp.sum$ar1)
# interseries
- res$rbar <- interseries.cor(rwl)
+ res$interrbar <- mean(interseries.cor(rwl)[,1])
# missing rings
zeds <- rwl == 0
@@ -26,7 +30,7 @@
else res$internalNAs <- internalNAs
# wee rings
- wee <- rwl > 0 & rwl < 0.003
+ wee <- rwl > 0 & rwl < 0.005
wee <- apply(wee,2,which)
wee <- sapply(wee, function(x) {as.numeric(names(x))} )
wee <- wee[lapply(wee,length)>0]
@@ -34,16 +38,17 @@
else res$small <- wee
options(warn = oldw)
-
- class(res) <- "rwl.report"
- res
+ res$rwl.class <- class(rwl)
+ res
}
-print.rwl.report <- function(x){
- cat("Number of dated series:",nrow(x$sum),"\n")
- cat("Avg series length:",mean(x$sum$year),"\n")
- cat("Span: ",min(x$sum$first), "-", max(x$sum$last), "\n")
- cat("Avg series intercorrelation:",mean(x$rbar[,1]), "\n")
+print.rwl.report <- function(x, ...){
+ cat("Number of dated series:",x$n,"\n")
+ cat("Avg series length:",x$segbar,"\n")
+ cat("Range: ", x$yr1 - x$yr0, "\n")
+ cat("Span: ",x$yr0, "-", x$yr1, "\n")
+ cat("Avg series intercorrelation:",x$interrbar, "\n")
+ cat("Avg AR1:",x$ar1bar, "\n")
cat("-------------\n")
cat("Absent rings listed by series \n")
if(length(x$zeros)==0) cat(" None \n")
@@ -59,6 +64,7 @@
cat("Internal NA values listed by series \n")
if(length(x$internalNAs)==0) cat(" None \n")
else{
+ cat("Warning: Internal NA are not standard practice and can break dplR \n")
for(i in 1:length(x$internalNAs)){
tmp = x$internalNAs[[i]]
if(length(tmp)==0) next()
@@ -67,7 +73,7 @@
}
}
cat("-------------\n")
- cat("Very small rings listed by series \n")
+ cat("Very small rings (< 0.005) listed by series \n")
if(length(x$small)==0) cat(" None \n")
else{
for(i in 1:length(x$small)){
Added: pkg/dplR/man/print.rwl.report.Rd
===================================================================
--- pkg/dplR/man/print.rwl.report.Rd (rev 0)
+++ pkg/dplR/man/print.rwl.report.Rd 2016-06-09 18:28:43 UTC (rev 1030)
@@ -0,0 +1,39 @@
+\encoding{UTF-8}
+\name{print.rwl.report}
+\alias{print.rwl.report}
+\title{Do some reporting on a RWL object}
+\description{
+ This function prints the results of \code{\link{rwl.report}}
+}
+\usage{
+\method{print}{rwl.report}(x, ...)
+}
+\arguments{
+ \item{x}{a \code{list} from \code{\link{rwl.report}}}
+ \item{\dots}{not implemented}
+}
+\details{
+ This function formats the \code{list} from \code{\link{rwl.report}} for the
+ user to have a summary report of the number of series, the mean length
+ of all the series, the first year, last year, the mean first-order
+ autocorrelation (via \code{\link{summary.rwl}}), the mean interseries
+ correlation (via \code{\link{interseries.cor}}), the years where a series has
+ a missing ring (zero), internal NA, or a very small ring (<0.005).
+}
+\value{
+ Invisible
+}
+\author{ Andy Bunn. Patched and improved by Mikko Korpela. }
+\seealso{ \code{\link{rwl.report}}, \code{\link{summary.rwl}},
+ \code{\link{interseries.cor}}
+}
+\examples{
+data("gp.rwl")
+rwl.report(gp.rwl)
+foo <- gp.rwl
+foo[177,1] <- NA
+foo[177:180,3] <- NA
+foo[185,4] <- 0.001
+rwl.report(foo)
+}
+\keyword{ manip }
Modified: pkg/dplR/man/rwl.report.Rd
===================================================================
--- pkg/dplR/man/rwl.report.Rd 2016-06-08 23:26:52 UTC (rev 1029)
+++ pkg/dplR/man/rwl.report.Rd 2016-06-09 18:28:43 UTC (rev 1030)
@@ -3,25 +3,37 @@
\alias{rwl.report}
\title{Do some reporting on a RWL object}
\description{
- This function...
+ This function generates a small report on a \code{rwl} (or \code{rwi}) object
+ that gives the user some basic information on the data including the number of
+ series, the span of the data, the mean interseries correlation, the number of
+ zeros, small rings, or internal \code{NA}, etc.
}
\usage{
-rwl.report(x)
+rwl.report(rwl)
}
\arguments{
- \item{x}{a \code{data.frame} of ring widths with
+ \item{rwl}{a \code{data.frame} of ring widths with
\code{rownames(\var{x})} containing years and \code{colnames(x)}
containing each series \acronym{ID} such as produced by
\code{\link{read.rwl}}}
}
\details{
- This...
+ This report is a \code{list} containing the number of series, the mean length
+ of all the series, the first year, last year, the mean first-order
+ autocorrelation (via \code{\link{summary.rwl}}), the mean interseries
+ correlation (via \code{\link{interseries.cor}}), the years where a series has
+ a missing ring (zero), internal NA, or a very small ring (<0.005).
+
+ This output of this function is not typically meant for the user to access
+ but has a \code{print} method that formats that data for the user.
}
\value{
- A \code{list} with...
+ A \code{list} with elements containing descriptive information on the
+ \code{rwl} object.
}
\author{ Andy Bunn. Patched and improved by Mikko Korpela. }
-\seealso{ \code{\link{read.rwl}}, \code{\link{summary.rwl}}
+\seealso{ \code{\link{read.rwl}}, \code{\link{summary.rwl}},
+ \code{\link{interseries.cor}}
}
\examples{
data("gp.rwl")
@@ -30,8 +42,6 @@
foo[177,1] <- NA
foo[177:180,3] <- NA
foo[185,4] <- 0.001
-x <- rwl.report(foo)
-class(x)
-x
+rwl.report(foo)
}
\keyword{ manip }
Modified: pkg/dplR/vignettes/intro-dplR.Rnw
===================================================================
--- pkg/dplR/vignettes/intro-dplR.Rnw 2016-06-08 23:26:52 UTC (rev 1029)
+++ pkg/dplR/vignettes/intro-dplR.Rnw 2016-06-09 18:28:43 UTC (rev 1030)
@@ -107,14 +107,14 @@
class(ca533) # note "rwl" class as well as "data.frame"
@
+
\subsection{Describing and Plotting Ring-Width Data}
Once a \code{rwl} data set has been read into R, there are a variety of ways to
-describe and visualize those data. For instance, we can plot a \code{rwl}
-object by showing either the segments arranged over time as straight lines or
-as a ``spaghetti plot.'' The \code{rwl} objects have a generic S3 method for
+describe and visualize those data. For instance, we can run a quick report using \code{rwl.report} that summarizes the \code{rwl} data and gives a few descriptive stats and also tells the user where the series have absent rings (zeros) and so on (more descriptive statistics like rbar and EPS are described below). We can also plot a \code{rwl} object by showing either the segments arranged over time as straight lines or as a ``spaghetti plot.'' The \code{rwl} objects have a generic S3 method for
\code{plot} and \code{summary}. See Figure~\ref{fig:rwl.plot}.
<<a, fig=TRUE>>=
+rwl.report(ca533)
plot(ca533, plot.type="spag")
@
\begin{figure}[ht]
@@ -220,22 +220,18 @@
\code{bai.in} and \code{bai.out}). See help pages for further
information.
+
\section{Descriptive Statistics}
-Either before or after standardization, it is natural to want to look at
-some common (and not-so common) descriptive statistics of a \code{rwl} object. The
-\code{rwl.stats} function is typically used on raw ring widths
-(the \code{rwl} object) and produces summary statistics. Here are summary
-statistics on the first five series in \code{ca533}.
+The \code{rwl.report} function above gave a very cursory look at the \code{rwl} data. Let's look at some common (and not-so common) descriptive statistics of a \code{rwl} object. The \code{rwl.stats} function is typically used on raw ring widths (the \code{rwl} object) and produces summary statistics. Here are summary statistics on the first five series in \code{ca533}.
<<>>=
-rwl.stats(ca533[1:5])
+rwl.stats(ca533[1:5]) # can also be run via summary(ca533)
@
These are common summary statistics like mean, median, etc. but also statistics
that are more specific to dendrochronology like the first-order autocorrelation
(\code{ar1}) and mean sensitivity (\code{sens1} and \code{sens2}).
-We would be remiss if we did not here
-mention that mean sensitivity is actually a terrible statistic that should
-rarely, if ever, be used \citep{Bunn2013}.
+We would be remiss if we did not here mention that mean sensitivity is actually
+a terrible statistic that should rarely, if ever, be used \citep{Bunn2013}.
It is also easy in dplR to compute commonly used descriptive statistics that
describe the correlation between series (both within and between tree
More information about the Dplr-commits
mailing list