[Dplr-commits] r1034 - in pkg/dplR: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Aug 10 21:40:38 CEST 2016
Author: andybunn
Date: 2016-08-10 21:40:38 +0200 (Wed, 10 Aug 2016)
New Revision: 1034
Modified:
pkg/dplR/R/rwl.report.R
pkg/dplR/man/rwl.report.Rd
Log:
more tweaks to rwl.report
Modified: pkg/dplR/R/rwl.report.R
===================================================================
--- pkg/dplR/R/rwl.report.R 2016-08-09 20:15:13 UTC (rev 1033)
+++ pkg/dplR/R/rwl.report.R 2016-08-10 19:40:38 UTC (rev 1034)
@@ -1,8 +1,10 @@
-rwl.report <- function(rwl){
+rwl.report <- function(rwl, small.thresh = NA, big.thresh = NA){
oldw <- getOption("warn")
options(warn = -1)
res <- list()
+ res$small.thresh <- small.thresh
+ res$big.thresh <- big.thresh
# get a summary
tmp.sum <- summary.rwl(rwl)
res$nseries <- ncol(rwl)
@@ -33,14 +35,28 @@
if(length(internalNAs)<1) res$internalNAs <- numeric(0)
else res$internalNAs <- internalNAs
- # wee rings
- 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]
- if(length(wee)<1) res$small <- numeric(0)
- else res$small <- wee
+ # small rings
+ if(is.na(small.thresh)) res$small <- numeric(0)
+ else {
+ small <- rwl > 0 & rwl < small.thresh
+ small <- apply(small,2,which)
+ small <- sapply(small, function(x) {as.numeric(names(x))} )
+ small <- small[lapply(small,length)>0]
+ if(length(small)<1) res$small <- numeric(0)
+ else res$small <- small
+ }
+ # big rings
+ if(is.na(big.thresh)) res$big <- numeric(0)
+ else {
+ big <- rwl > big.thresh
+ big <- apply(big,2,which)
+ big <- sapply(big, function(x) {as.numeric(names(x))} )
+ big <- big[lapply(big,length)>0]
+ if(length(big)<1) res$big <- numeric(0)
+ else res$big <- big
+ }
+
options(warn = oldw)
class(res) <- "rwl.report"
res
@@ -80,16 +96,31 @@
sep = " ")
}
}
- cat("-------------\n")
- cat("Years with 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)){
- tmp = x$small[[i]]
- if(length(tmp)==0) next()
- cat(" Series", names(x$small)[i],"--",tmp,"\n",
- sep = " ")
+ if(!is.na(x$small.thresh)){
+ cat("-------------\n")
+ cat("Years with values <", x$small.thresh, "listed by series \n")
+ if(length(x$small)==0) cat(" None \n")
+ else{
+ for(i in 1:length(x$small)){
+ tmp = x$small[[i]]
+ if(length(tmp)==0) next()
+ cat(" Series", names(x$small)[i],"--",tmp,"\n",
+ sep = " ")
+ }
}
}
+ if(!is.na(x$big.thresh)){
+ cat("-------------\n")
+ cat("Years with values >", x$big.thresh, " listed by series \n")
+ if(length(x$big)==0) cat(" None \n")
+ else{
+ for(i in 1:length(x$big)){
+ tmp = x$big[[i]]
+ if(length(tmp)==0) next()
+ cat(" Series", names(x$big)[i],"--",tmp,"\n",
+ sep = " ")
+ }
+ }
+ }
invisible(x)
}
Modified: pkg/dplR/man/rwl.report.Rd
===================================================================
--- pkg/dplR/man/rwl.report.Rd 2016-08-09 20:15:13 UTC (rev 1033)
+++ pkg/dplR/man/rwl.report.Rd 2016-08-10 19:40:38 UTC (rev 1034)
@@ -6,23 +6,28 @@
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.
+ missing rings (zeros), internal \code{NA} values, and rings that are very small,
+ or very large.
}
\usage{
-rwl.report(rwl)
+rwl.report(rwl,small.thresh=NA,big.thresh=NA)
}
\arguments{
\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}}}
+ \item{small.thresh}{a \code{numeric} value for the threshold value that will cause
+ small rings to be listed. If values is \code{NA} this will be omitted.}
+ \item{big.thresh}{a \code{numeric} value for the threshold value that will cause
+ large rings to be listed. If values is \code{NA} this will be omitted.}
}
\details{
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).
+ a missing ring (zero), internal NA, very small ring, and very large rings.
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.
@@ -37,11 +42,9 @@
}
\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)
+rwl.report(rwl = gp.rwl)
+# list very small (smallest 1pct) of rings as well
+one.pct <- quantile(gp.rwl[gp.rwl != 0], na.rm=TRUE, probs=0.01)
+rwl.report(rwl = gp.rwl, small.thresh = one.pct)
}
\keyword{ manip }
More information about the Dplr-commits
mailing list