From noreply at r-forge.r-project.org Mon Jun 6 12:05:16 2016 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 6 Jun 2016 12:05:16 +0200 (CEST) Subject: [Dplr-commits] r1026 - pkg/dplR/R Message-ID: <20160606100516.806E5187297@r-forge.r-project.org> Author: zang Date: 2016-06-06 12:05:16 +0200 (Mon, 06 Jun 2016) New Revision: 1026 Modified: pkg/dplR/R/sea.R Log: sea() simplified and computation of p-values fixed; computation of p-values and CI bands for sea() now based on ecdf() and quantile() functions. Modified: pkg/dplR/R/sea.R =================================================================== --- pkg/dplR/R/sea.R 2016-03-16 22:01:26 UTC (rev 1025) +++ pkg/dplR/R/sea.R 2016-06-06 10:05:16 UTC (rev 1026) @@ -43,36 +43,28 @@ ## calculate significance for each (lagged) year ## compute confidence bands, too p <- rep(NA_real_, m) - w <- resample - ci_pos <- floor(resample * c(0.025, 0.975, 0.005, 0.995)) - ci <- apply(apply(re.table, 2, sort), 2, function(x) { - x[ci_pos] - }) + re_ecdfs <- apply(re.table, 2, ecdf) + ci <- apply(re.table, 2, quantile, + probs = c(0.025, 0.975, 0.005, 0.995) + ) + + if (resample < 1000) { + warning("'resample' is lower than 1000, potentially leading to less accuracy in estimating p-values and confidence bands.") + } + for (i in seq_len(m)) { if (is.na(se[i])) { warning(gettextf("NA result at position %d. ", i), "You could check whether 'key' years are in range.") - } else if (se[i] < 0) { # superposed value < 0, it is + } else { + if (se[i] < 0) { # superposed value < 0, it is # tested whether is # significantly LOWER than # random values - if (!any(re.table[, i] < se[i])) { - p[i] <- 0 - warning(gettextf("Exact p-value (< %f) could not be estimated for superposed epoch at position %d. ", - 1 / resample, i), - "You could try a higher value for 'resample'.") - } else { - p[i] <- (tail(which(sort(re.table[, i]) < se[i]), 1) * 2) / w + p[i] <- re_ecdfs[[i]](se[i]) + } else { # ditto, but v.v. + p[i] <- 1 - re_ecdfs[[i]](se[i]) } - } else { # ditto, but v.v. - if (!any(re.table[, i] > se[i])) { - p[i] <- 0 - warning(gettextf("Exact p-value (< %f) could not be estimated for superposed epoch at position %d. ", - 1 / resample, i), - "You could try a higher value for 'resample'.") - } else { - p[i] <- ((w - which(sort(re.table[, i]) > se[i])[1]) * 2) / w - } } } data.frame(lag = c(-lag:lag), @@ -82,5 +74,6 @@ ci.95.lower = ci[1,], ci.95.upper = ci[2,], ci.99.lower = ci[3,], - ci.99.upper = ci[4,]) + ci.99.upper = ci[4,] + ) } From noreply at r-forge.r-project.org Thu Jun 9 01:19:00 2016 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jun 2016 01:19:00 +0200 (CEST) Subject: [Dplr-commits] r1027 - in pkg/dplR: . R man Message-ID: <20160608231900.F0AA0180A8E@r-forge.r-project.org> Author: andybunn Date: 2016-06-09 01:19:00 +0200 (Thu, 09 Jun 2016) New Revision: 1027 Added: pkg/dplR/R/rwl.report.R pkg/dplR/man/rwl.report.Rd Modified: pkg/dplR/ChangeLog pkg/dplR/NAMESPACE pkg/dplR/R/helpers.R Log: rwl.report is a new function to provide a summary of information about an rwl object. This is still very much a work in progress. Modified: pkg/dplR/ChangeLog =================================================================== --- pkg/dplR/ChangeLog 2016-06-06 10:05:16 UTC (rev 1026) +++ pkg/dplR/ChangeLog 2016-06-08 23:19:00 UTC (rev 1027) @@ -5,6 +5,27 @@ - Added Friedman under method argument in the help file. It was ommitted by mistake. +File: helpers.R +----------------- + +- Added function find.internal.na() that reutrns the index of internal NA in a series. This will be used by the rwl.report() function and could be used (maybe) by the fill.internal.NA + +File: rwl.report.R +----------------- + +- Added function find.internal.na() that reutrns the index of internal NA in a series. This will be used by the ringReport() function and could be used (maybe) by the fill.internal.NA + +File: NAMESPACE +----------------- + +- Added rwl.report to export + +File: sea.R +----------------- + +- Note on commit from Zang: sea() simplified and computation of p-values fixed; computation of p-values and CI bands for sea() now based on ecdf() and quantile() functions. + + * CHANGES IN dplR VERSION 1.6.4 File: DESCRIPTION Modified: pkg/dplR/NAMESPACE =================================================================== --- pkg/dplR/NAMESPACE 2016-06-06 10:05:16 UTC (rev 1026) +++ pkg/dplR/NAMESPACE 2016-06-08 23:19:00 UTC (rev 1027) @@ -39,6 +39,8 @@ importFrom(XML, xmlEventParse) +importFrom(plyr, alply) + export(autoread.ids, bai.in, bai.out, ccf.series.rwl, chron, cms, combine.rwl, common.interval, corr.rwl.seg, corr.series.seg, crn.plot, detrend, detrend.series, ffcsaps, fill.internal.NA, @@ -52,9 +54,10 @@ write.compact, write.crn, write.rwl, write.tridas, write.tucson, plot.rwl, interseries.cor, summary.rwl, plot.crn, insert.ring, delete.ring, xskel.ccf.plot, xskel.plot, - latexify, latexDate, rasterPlot, treeMean) + latexify, latexDate, rasterPlot, treeMean, rwl.report, print.rwl.report) S3method(print, redfit) S3method(plot, rwl) S3method(plot, crn) S3method(summary, rwl) +S3method(print, rwl.report) Modified: pkg/dplR/R/helpers.R =================================================================== --- pkg/dplR/R/helpers.R 2016-06-06 10:05:16 UTC (rev 1026) +++ pkg/dplR/R/helpers.R 2016-06-08 23:19:00 UTC (rev 1027) @@ -398,3 +398,28 @@ } y } + + +# Looks for internal NA in a series. Returns the position of internal NA via which +find.internal.na <- function(x) { + x.na <- is.na(x) + x.ok <- which(!x.na) + n.ok <- length(x.ok) + if (n.ok <= 1) { + internal.na <- 0 # NA, NULL? + return(internal.na) + } + + first.ok <- x.ok[1] + last.ok <- x.ok[n.ok] + + if (last.ok - first.ok + 1 > n.ok) { + first.to.last <- first.ok:last.ok + x.notok <- which(x.na) + internal.na <- x.notok[x.notok %in% first.to.last] + } + else { + internal.na <- 0 # NA, NULL? + } + internal.na +} Added: pkg/dplR/R/rwl.report.R =================================================================== --- pkg/dplR/R/rwl.report.R (rev 0) +++ pkg/dplR/R/rwl.report.R 2016-06-08 23:19:00 UTC (rev 1027) @@ -0,0 +1,78 @@ +rwl.report <- function(rwl){ + oldw <- getOption("warn") + options(warn = -1) + + res <- list() + # get a summary + res$sum <- summary.rwl(rwl) + + # interseries + res$rbar <- interseries.cor(rwl) + + # missing rings + zeds <- rwl == 0 + zeds <- apply(zeds,2,which) + zeds <- sapply(zeds, function(x) {as.numeric(names(x))} ) + zeds <- zeds[lapply(zeds,length)>0] + if(length(zeds)<1) res$zeros <- numeric(0) + else res$zeros <- zeds + + # internal NA + internalNAs <- alply(rwl, 2, find.internal.na) # like apply but forces a list + names(internalNAs) <- names(rwl) + internalNAs <- sapply(internalNAs, function(x) {as.numeric(rownames(rwl)[x])} ) + internalNAs <- internalNAs[lapply(internalNAs,length)>0] + if(length(internalNAs)<1) res$internalNAs <- numeric(0) + else res$internalNAs <- internalNAs + + # wee rings + wee <- rwl > 0 & rwl < 0.003 + wee <- apply(wee,2,which) + res$wee <- sapply(wee, function(x) {as.numeric(names(x))} ) + + options(warn = oldw) + + class(res) <- "rwl.report" + 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") + cat("-------------\n") + cat("Absent rings listed by series \n") + if(length(x$zeros)==0) cat(" None \n") + else{ + for(i in 1:length(x$zeros)){ + tmp = x$zeros[[i]] + if(length(tmp)==0) next() + cat(" Series", names(x$zeros)[i],"--",tmp,"\n", + sep = " ") + } + } + cat("-------------\n") + cat("Internal NA values listed by series \n") + if(length(x$internalNAs)==0) cat(" None \n") + else{ + for(i in 1:length(x$internalNAs)){ + tmp = x$internalNAs[[i]] + if(length(tmp)==0) next() + cat(" Series", names(x$internalNAs)[i],"--",tmp,"\n", + sep = " ") + } + } + cat("-------------\n") + cat("Very small rings listed by series \n") + if(length(x$wee)==0) cat(" None \n") + else{ + for(i in 1:length(x$wee)){ + tmp = x$wee[[i]] + if(length(tmp)==0) next() + cat("Series", names(x$wee)[i],"--",tmp,"\n", + sep = " ") + } + } + invisible(x) +} Added: pkg/dplR/man/rwl.report.Rd =================================================================== --- pkg/dplR/man/rwl.report.Rd (rev 0) +++ pkg/dplR/man/rwl.report.Rd 2016-06-08 23:19:00 UTC (rev 1027) @@ -0,0 +1,36 @@ +\encoding{UTF-8} +\name{rwl.report} +\alias{rwl.report} +\title{Do some reporting on a RWL object} +\description{ + This function... +} +\usage{ +rwl.report(x) +} +\arguments{ + \item{x}{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... +} +\value{ + A \code{list} with... +} +\author{ Andy Bunn. Patched and improved by Mikko Korpela. } +\seealso{ \code{\link{read.rwl}}, \code{\link{summary.rwl}} +} +\examples{ +data("gp.rwl") +rwl.report(gp.rwl) +foo <- gp.rwl +foo[177,1] <- NA +foo[177:180,3] <- NA +rwl.report(foo) +x <- rwl.report(foo) +x +} +\keyword{ manip } From noreply at r-forge.r-project.org Thu Jun 9 01:20:14 2016 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jun 2016 01:20:14 +0200 (CEST) Subject: [Dplr-commits] r1028 - pkg/dplR Message-ID: <20160608232014.4FFEF18447B@r-forge.r-project.org> Author: andybunn Date: 2016-06-09 01:20:13 +0200 (Thu, 09 Jun 2016) New Revision: 1028 Modified: pkg/dplR/ChangeLog Log: more info in rwl.report in changelog Modified: pkg/dplR/ChangeLog =================================================================== --- pkg/dplR/ChangeLog 2016-06-08 23:19:00 UTC (rev 1027) +++ pkg/dplR/ChangeLog 2016-06-08 23:20:13 UTC (rev 1028) @@ -13,12 +13,14 @@ File: rwl.report.R ----------------- -- Added function find.internal.na() that reutrns the index of internal NA in a series. This will be used by the ringReport() function and could be used (maybe) by the fill.internal.NA +- Added function to provide a summary of information about an rwl object. This is still very much a work in progress. File: NAMESPACE ----------------- - Added rwl.report to export +- Added rwl.report print method +- Added export from plyr File: sea.R ----------------- From noreply at r-forge.r-project.org Thu Jun 9 01:26:53 2016 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jun 2016 01:26:53 +0200 (CEST) Subject: [Dplr-commits] r1029 - in pkg/dplR: R man Message-ID: <20160608232653.181A718140F@r-forge.r-project.org> Author: andybunn Date: 2016-06-09 01:26:52 +0200 (Thu, 09 Jun 2016) New Revision: 1029 Modified: pkg/dplR/R/rwl.report.R pkg/dplR/man/rwl.report.Rd Log: one last tweak for the day on rwl.report Modified: pkg/dplR/R/rwl.report.R =================================================================== --- pkg/dplR/R/rwl.report.R 2016-06-08 23:20:13 UTC (rev 1028) +++ pkg/dplR/R/rwl.report.R 2016-06-08 23:26:52 UTC (rev 1029) @@ -28,8 +28,11 @@ # wee rings wee <- rwl > 0 & rwl < 0.003 wee <- apply(wee,2,which) - res$wee <- sapply(wee, function(x) {as.numeric(names(x))} ) - + 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 + options(warn = oldw) class(res) <- "rwl.report" @@ -65,12 +68,12 @@ } cat("-------------\n") cat("Very small rings listed by series \n") - if(length(x$wee)==0) cat(" None \n") + if(length(x$small)==0) cat(" None \n") else{ - for(i in 1:length(x$wee)){ - tmp = x$wee[[i]] + for(i in 1:length(x$small)){ + tmp = x$small[[i]] if(length(tmp)==0) next() - cat("Series", names(x$wee)[i],"--",tmp,"\n", + cat(" Series", names(x$small)[i],"--",tmp,"\n", sep = " ") } } Modified: pkg/dplR/man/rwl.report.Rd =================================================================== --- pkg/dplR/man/rwl.report.Rd 2016-06-08 23:20:13 UTC (rev 1028) +++ pkg/dplR/man/rwl.report.Rd 2016-06-08 23:26:52 UTC (rev 1029) @@ -29,8 +29,9 @@ foo <- gp.rwl foo[177,1] <- NA foo[177:180,3] <- NA -rwl.report(foo) +foo[185,4] <- 0.001 x <- rwl.report(foo) +class(x) x } \keyword{ manip } From noreply at r-forge.r-project.org Thu Jun 9 20:28:43 2016 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jun 2016 20:28:43 +0200 (CEST) Subject: [Dplr-commits] r1030 - in pkg/dplR: . R man vignettes Message-ID: <20160609182843.F3A1F187ADB@r-forge.r-project.org> 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}. <>= +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 From noreply at r-forge.r-project.org Thu Jun 9 21:53:13 2016 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 9 Jun 2016 21:53:13 +0200 (CEST) Subject: [Dplr-commits] r1031 - pkg/dplR/R Message-ID: <20160609195313.2C857186A65@r-forge.r-project.org> Author: andybunn Date: 2016-06-09 21:53:11 +0200 (Thu, 09 Jun 2016) New Revision: 1031 Modified: pkg/dplR/R/rwl.report.R Log: fix typos Modified: pkg/dplR/R/rwl.report.R =================================================================== --- pkg/dplR/R/rwl.report.R 2016-06-09 18:28:43 UTC (rev 1030) +++ pkg/dplR/R/rwl.report.R 2016-06-09 19:53:11 UTC (rev 1031) @@ -5,7 +5,8 @@ res <- list() # get a summary tmp.sum <- summary.rwl(rwl) - res$n <- nrow(tmp.sum) + res$nseries <- ncol(rwl) + res$n <- length(rwl[!is.na(rwl)]) res$segbar <- mean(tmp.sum$year) res$yr0 <- min(tmp.sum$first) res$yr1 <- max(tmp.sum$last) @@ -15,6 +16,7 @@ # missing rings zeds <- rwl == 0 + res$nzeros <- table(zeds)["TRUE"] zeds <- apply(zeds,2,which) zeds <- sapply(zeds, function(x) {as.numeric(names(x))} ) zeds <- zeds[lapply(zeds,length)>0] @@ -38,12 +40,13 @@ else res$small <- wee options(warn = oldw) - res$rwl.class <- class(rwl) + class(res) <- "rwl.report" res } print.rwl.report <- function(x, ...){ - cat("Number of dated series:",x$n,"\n") + cat("Number of dated series:",x$nseries,"\n") + cat("Number of measurements:",x$n,"\n") cat("Avg series length:",x$segbar,"\n") cat("Range: ", x$yr1 - x$yr0, "\n") cat("Span: ",x$yr0, "-", x$yr1, "\n") @@ -59,6 +62,7 @@ cat(" Series", names(x$zeros)[i],"--",tmp,"\n", sep = " ") } + cat(x$nzeros, "absent rings (", round(x$nzeros/x$n * 100, 3),"%)\n") } cat("-------------\n") cat("Internal NA values listed by series \n")