From noreply at r-forge.r-project.org Mon Jun 1 13:35:01 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 1 Jun 2015 13:35:01 +0200 (CEST) Subject: [Dplr-commits] r987 - pkg/dplR Message-ID: <20150601113501.19C0618734D@r-forge.r-project.org> Author: mvkorpel Date: 2015-06-01 13:35:00 +0200 (Mon, 01 Jun 2015) New Revision: 987 Modified: pkg/dplR/ChangeLog pkg/dplR/DESCRIPTION Log: Changes already released as part of dplR 1.6.3 on CRAN Modified: pkg/dplR/ChangeLog =================================================================== --- pkg/dplR/ChangeLog 2015-05-28 08:59:43 UTC (rev 986) +++ pkg/dplR/ChangeLog 2015-06-01 11:35:00 UTC (rev 987) @@ -32,6 +32,11 @@ requirement (>= 0.5-2) was a mistake. - Updated version requirement: R (>= 2.15.2). For some reason, R CMD check does not play nice with testthat on earlier versions of R. +- Removed one of the URLs in the URL field. BDR sent and email saying that + having two URLs was breaking R and that we should put a comma in betwixt + them. But the comma is problematic as it is a valid part of some URLs. + We deicded the better part of valor was to keep only one URL and not fight + this particular battle. File: NAMESPACE --------------- Modified: pkg/dplR/DESCRIPTION =================================================================== --- pkg/dplR/DESCRIPTION 2015-05-28 08:59:43 UTC (rev 986) +++ pkg/dplR/DESCRIPTION 2015-06-01 11:35:00 UTC (rev 987) @@ -29,6 +29,5 @@ used in dendrochronology. LazyData: no License: GPL (>= 2) -URL: http://huxley.wwu.edu/trl/htrl-dplr - http://R-Forge.R-project.org/projects/dplr/ +URL: http://R-Forge.R-project.org/projects/dplr/ MailingList: https://groups.google.com/d/forum/dplr-help From noreply at r-forge.r-project.org Mon Jun 1 13:36:53 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 1 Jun 2015 13:36:53 +0200 (CEST) Subject: [Dplr-commits] r988 - in tags: . dplR-1.6.3 Message-ID: <20150601113653.7A6C8186180@r-forge.r-project.org> Author: mvkorpel Date: 2015-06-01 13:36:53 +0200 (Mon, 01 Jun 2015) New Revision: 988 Added: tags/dplR-1.6.3/ Log: dplR 1.6.3 Property changes on: tags/dplR-1.6.3 ___________________________________________________________________ Added: svn:ignore + dplR-Ex.R svn*.tmp .* *~ .Rproj.user *.Rproj Added: svn:auto-props + *.c = svn:eol-style=LF *.h = svn:eol-style=LF Makefile = svn:eol-style=LF *.po = svn:eol-style=native *.pot = svn:eol-style=native *.R = svn:eol-style=native *.Rd = svn:eol-style=native *.Rnw = svn:eol-style=native *.sty = svn:eol-style=native Added: svn:mergeinfo + /branches/dplR-R-2.15:466-506 /branches/redfit:662-700 From noreply at r-forge.r-project.org Mon Jun 1 13:51:23 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 1 Jun 2015 13:51:23 +0200 (CEST) Subject: [Dplr-commits] r989 - pkg/dplR Message-ID: <20150601115123.F3CBF187A34@r-forge.r-project.org> Author: mvkorpel Date: 2015-06-01 13:51:23 +0200 (Mon, 01 Jun 2015) New Revision: 989 Modified: pkg/dplR/ChangeLog pkg/dplR/DESCRIPTION Log: * Fixed a few typos in ChangeLog * Development of dplR 1.6.4 (or other greater version number) begins Modified: pkg/dplR/ChangeLog =================================================================== --- pkg/dplR/ChangeLog 2015-06-01 11:36:53 UTC (rev 988) +++ pkg/dplR/ChangeLog 2015-06-01 11:51:23 UTC (rev 989) @@ -1,3 +1,7 @@ +* CHANGES IN dplR VERSION 1.6.4 + + + * CHANGES IN dplR VERSION 1.6.3 File: crn.plot.R @@ -32,10 +36,10 @@ requirement (>= 0.5-2) was a mistake. - Updated version requirement: R (>= 2.15.2). For some reason, R CMD check does not play nice with testthat on earlier versions of R. -- Removed one of the URLs in the URL field. BDR sent and email saying that +- Removed one of the URLs in the URL field. BDR sent an email saying that having two URLs was breaking R and that we should put a comma in betwixt them. But the comma is problematic as it is a valid part of some URLs. - We deicded the better part of valor was to keep only one URL and not fight + We decided the better part of valor was to keep only one URL and not fight this particular battle. File: NAMESPACE @@ -69,7 +73,7 @@ more robust against unusual values: wrong type, "bytes" encoding, zero length or NA. Some values that previously failed are now silently accepted by coercion to character, extraction of first - element when a single string is expected, and / or intepretation + element when a single string is expected, and / or interpretation of a zero length argument as an empty string. NA is equivalent to "NA" in detrend.series() and skel.plot() where it is used for plotting or text output, but forbidden otherwise, e.g. in chron(). @@ -114,7 +118,7 @@ - New argument 'edge.zeros', TRUE (default) or FALSE. If TRUE, possible leading and trailing zero values in tree-ring series are kept. If FALSE, such values are dropped. The latter is how the - function has worked between (pre-)release 1.5.5 and the previoius + function has worked between (pre-)release 1.5.5 and the previous release, and may be considered a bug or a misfeature. To reiterate, the default behavior has changed in some cases. The alternative, 1.5.5--1.6.2 behavior can be restored by changing the @@ -355,7 +359,7 @@ - Added summary.rwl as an S3Method. - Added insert and delete.ring functions. -File: xskel.ccf.plot.R and xskel.plot.R and +File: xskel.ccf.plot.R and xskel.plot.R --------------- - New plotting functions to help crossdate with skeleton plot Modified: pkg/dplR/DESCRIPTION =================================================================== --- pkg/dplR/DESCRIPTION 2015-06-01 11:36:53 UTC (rev 988) +++ pkg/dplR/DESCRIPTION 2015-06-01 11:51:23 UTC (rev 989) @@ -2,8 +2,8 @@ Package: dplR Type: Package Title: Dendrochronology Program Library in R -Version: 1.6.3 -Date: 2015-05-28 +Version: 1.6.4 +Date: 2015-06-01 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", From noreply at r-forge.r-project.org Mon Jun 1 22:20:43 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 1 Jun 2015 22:20:43 +0200 (CEST) Subject: [Dplr-commits] r990 - in pkg/dplR: . R man Message-ID: <20150601202043.75CAC185E6C@r-forge.r-project.org> Author: andybunn Date: 2015-06-01 22:20:42 +0200 (Mon, 01 Jun 2015) New Revision: 990 Added: pkg/dplR/R/treeMean.R pkg/dplR/man/treeMean.Rd Modified: pkg/dplR/ChangeLog pkg/dplR/NAMESPACE Log: New function to calculate the mean value for a single tree across multiple cores. Still needs error checking and some more work on the help page. Modified: pkg/dplR/ChangeLog =================================================================== --- pkg/dplR/ChangeLog 2015-06-01 11:51:23 UTC (rev 989) +++ pkg/dplR/ChangeLog 2015-06-01 20:20:42 UTC (rev 990) @@ -1,7 +1,10 @@ * CHANGES IN dplR VERSION 1.6.4 +File: treeMean.R +------------- +- Made a new function to calculate the mean value of each tree when there are + multiple cores. - * CHANGES IN dplR VERSION 1.6.3 File: crn.plot.R @@ -36,10 +39,10 @@ requirement (>= 0.5-2) was a mistake. - Updated version requirement: R (>= 2.15.2). For some reason, R CMD check does not play nice with testthat on earlier versions of R. -- Removed one of the URLs in the URL field. BDR sent an email saying that +- Removed one of the URLs in the URL field. BDR sent and email saying that having two URLs was breaking R and that we should put a comma in betwixt them. But the comma is problematic as it is a valid part of some URLs. - We decided the better part of valor was to keep only one URL and not fight + We deicded the better part of valor was to keep only one URL and not fight this particular battle. File: NAMESPACE Modified: pkg/dplR/NAMESPACE =================================================================== --- pkg/dplR/NAMESPACE 2015-06-01 11:51:23 UTC (rev 989) +++ pkg/dplR/NAMESPACE 2015-06-01 20:20:42 UTC (rev 990) @@ -52,7 +52,7 @@ 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) + latexify, latexDate, rasterPlot, treeMean) S3method(print, redfit) S3method(plot, rwl) Added: pkg/dplR/R/treeMean.R =================================================================== --- pkg/dplR/R/treeMean.R (rev 0) +++ pkg/dplR/R/treeMean.R 2015-06-01 20:20:42 UTC (rev 990) @@ -0,0 +1,14 @@ +treeMean <- function(rwl,ids){ + rwl2 <- as.matrix(rwl) + trees <- ids$tree + uTrees <- unique(trees) + res <- matrix(NA, nrow=nrow(rwl2), ncol=length(uTrees)) + for (i in seq(along=uTrees)) { + res[,i] <- rowMeans(rwl2[,trees == uTrees[i], drop=FALSE], na.rm=TRUE) + } + res[is.nan(res)] <- NA + res <- as.data.frame(res) + colnames(res) <- uTrees + rownames(res) <- rownames(rwl) + res +} Added: pkg/dplR/man/treeMean.Rd =================================================================== --- pkg/dplR/man/treeMean.Rd (rev 0) +++ pkg/dplR/man/treeMean.Rd 2015-06-01 20:20:42 UTC (rev 990) @@ -0,0 +1,50 @@ +\encoding{UTF-8} +\name{treeMean} +\alias{treeMean} +\title{Calculate mean across cores in a tree} +\description{ + This function calculates the mean value for each tree in a rwl or rwi object. +} +\usage{ +treeMean(rwl, ids) +} +\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}}} + \item{ids}{ an optional \code{data.frame} with column one named + \code{"tree"} giving a \code{numeric} \acronym{ID} for each tree and + column two named \code{"core"} giving a \code{numeric} \acronym{ID} + for each core. Defaults to one core per tree as\cr + \code{data.frame(tree=1:ncol(\var{rwi}), core=rep(1, ncol(\var{rwi})))}. } +} +\details{ + Here. +} +\value{ + A \code{data.frame} with the means of each tree. +} + +\author{ Andy Bunn. Patched and improved by Mikko Korpela. } + +\seealso{ \code{\link{read.rwl}}, \code{\link{read.ids}} +} +\examples{ +data(gp.rwl) +gp.ids <- read.ids(gp.rwl, stc = c(0, 2, 1)) +gp.treeMean <- treeMean(gp.rwl,gp.ids) + +data(ca533) +ca533.treeMean <-treeMean(ca533,autoread.ids(ca533)) +# look at an example of two cores per tree +tail(ca533[,c("CAM031","CAM032"),drop=FALSE]) +tail(rowMeans(ca533[,c("CAM031","CAM032"),drop=FALSE],na.rm=TRUE)) +tail(ca533.treeMean[,"3",drop=FALSE]) +# look at an example of single tree +ca533[,"CAM011",drop=FALSE] +ca533.treeMean[,1] +ca533[905,"CAM011"] +ca533.treeMean[905,1] +} +\keyword{ manip } From noreply at r-forge.r-project.org Mon Jun 1 22:26:22 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 1 Jun 2015 22:26:22 +0200 (CEST) Subject: [Dplr-commits] r991 - pkg/dplR Message-ID: <20150601202622.F30B41851D9@r-forge.r-project.org> Author: andybunn Date: 2015-06-01 22:26:22 +0200 (Mon, 01 Jun 2015) New Revision: 991 Modified: pkg/dplR/ChangeLog Log: treeMean to namespace. Modified: pkg/dplR/ChangeLog =================================================================== --- pkg/dplR/ChangeLog 2015-06-01 20:20:42 UTC (rev 990) +++ pkg/dplR/ChangeLog 2015-06-01 20:26:22 UTC (rev 991) @@ -5,6 +5,10 @@ - Made a new function to calculate the mean value of each tree when there are multiple cores. +File: NAMESPACE +------------- +- Added treeMean function. + * CHANGES IN dplR VERSION 1.6.3 File: crn.plot.R From noreply at r-forge.r-project.org Tue Jun 2 17:03:07 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 2 Jun 2015 17:03:07 +0200 (CEST) Subject: [Dplr-commits] r992 - in pkg/dplR: . R man Message-ID: <20150602150307.862E61878E7@r-forge.r-project.org> Author: mvkorpel Date: 2015-06-02 17:03:06 +0200 (Tue, 02 Jun 2015) New Revision: 992 Modified: pkg/dplR/DESCRIPTION pkg/dplR/R/treeMean.R pkg/dplR/man/treeMean.Rd Log: In treeMean(), * Renamed first argument to 'x' (was already named so in the \arguments section of the .Rd file). * Inputs are checked. * A warning is produced if there are missing tree IDs, which is probably a rare occasion. The series with NA IDs are now averaged. Is this desirable or not? The resulting average may not be very useful. Prior to my changes, the function would return a completely NA-filled "average" for series with a missing tree ID. * Default 'ids' is NULL, means one core per tree (no averaging). * Row names of 'ids' (if any) are matched to column names of 'x'. * Small optimizations were made. * Code and examples were reformatted a bit. * Note: Should the return value inherit class "rwl"? Modified: pkg/dplR/DESCRIPTION =================================================================== --- pkg/dplR/DESCRIPTION 2015-06-01 20:26:22 UTC (rev 991) +++ pkg/dplR/DESCRIPTION 2015-06-02 15:03:06 UTC (rev 992) @@ -3,7 +3,7 @@ Type: Package Title: Dendrochronology Program Library in R Version: 1.6.4 -Date: 2015-06-01 +Date: 2015-06-02 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", Modified: pkg/dplR/R/treeMean.R =================================================================== --- pkg/dplR/R/treeMean.R 2015-06-01 20:26:22 UTC (rev 991) +++ pkg/dplR/R/treeMean.R 2015-06-02 15:03:06 UTC (rev 992) @@ -1,14 +1,39 @@ -treeMean <- function(rwl,ids){ - rwl2 <- as.matrix(rwl) - trees <- ids$tree - uTrees <- unique(trees) - res <- matrix(NA, nrow=nrow(rwl2), ncol=length(uTrees)) - for (i in seq(along=uTrees)) { - res[,i] <- rowMeans(rwl2[,trees == uTrees[i], drop=FALSE], na.rm=TRUE) - } - res[is.nan(res)] <- NA - res <- as.data.frame(res) - colnames(res) <- uTrees - rownames(res) <- rownames(rwl) - res +treeMean <- function(x, ids = NULL) { + ## If 'ids' is NULL then assume one core per tree (no averaging) + if (is.null(ids)) { + res <- as.data.frame(x) + names(res) <- seq_len(length(res)) + return(res) + } + x2 <- as.matrix(x) + if (!is.data.frame(ids) || !("tree" %in% names(ids))) { + stop("'ids' must be a data.frame with column 'tree'") + } + colnames.x <- colnames(x2) + trees <- as.matrix(ids["tree"]) + rownames.ids <- rownames(trees) + ## If all column names in 'x' are present in the set of row + ## names in 'ids', arrange 'ids' to matching order + if (!is.null(rownames.ids) && !is.null(colnames.x) && + anyDuplicated(colnames.x) == 0 && + all(colnames.x %in% rownames.ids)) { + trees <- trees[colnames.x, ] + } else if (length(trees) == ncol(x2)) { + trees <- as.vector(trees) + } else { + stop("dimension problem: ", "'ncol(x)' != 'nrow(ids)'") + } + uTrees <- unique(trees) + if (any(is.na(uTrees))) { + warning("series with missing tree IDs, will be averaged") + } + matches <- match(trees, uTrees) + res <- matrix(NA_real_, nrow=nrow(x2), ncol=length(uTrees)) + for (i in seq_along(uTrees)) { + res[, i] <- rowMeans(x2[, matches == i, drop=FALSE], na.rm=TRUE) + } + res[is.nan(res)] <- NA_real_ + res <- as.data.frame(res, row.names = rownames(x2)) + names(res) <- uTrees + res } Modified: pkg/dplR/man/treeMean.Rd =================================================================== --- pkg/dplR/man/treeMean.Rd 2015-06-01 20:26:22 UTC (rev 991) +++ pkg/dplR/man/treeMean.Rd 2015-06-02 15:03:06 UTC (rev 992) @@ -6,7 +6,7 @@ This function calculates the mean value for each tree in a rwl or rwi object. } \usage{ -treeMean(rwl, ids) +treeMean(x, ids = NULL) } \arguments{ \item{x}{a \code{data.frame} of ring widths with @@ -33,18 +33,18 @@ \examples{ data(gp.rwl) gp.ids <- read.ids(gp.rwl, stc = c(0, 2, 1)) -gp.treeMean <- treeMean(gp.rwl,gp.ids) +gp.treeMean <- treeMean(gp.rwl, gp.ids) data(ca533) -ca533.treeMean <-treeMean(ca533,autoread.ids(ca533)) +ca533.treeMean <- treeMean(ca533, autoread.ids(ca533)) # look at an example of two cores per tree -tail(ca533[,c("CAM031","CAM032"),drop=FALSE]) -tail(rowMeans(ca533[,c("CAM031","CAM032"),drop=FALSE],na.rm=TRUE)) -tail(ca533.treeMean[,"3",drop=FALSE]) +tail(ca533[, c("CAM031", "CAM032"), drop=FALSE]) +tail(rowMeans(ca533[, c("CAM031", "CAM032"), drop=FALSE], na.rm=TRUE)) +tail(ca533.treeMean[, "3", drop=FALSE]) # look at an example of single tree -ca533[,"CAM011",drop=FALSE] -ca533.treeMean[,1] -ca533[905,"CAM011"] -ca533.treeMean[905,1] +ca533[, "CAM011", drop=FALSE] +ca533.treeMean[, 1] +ca533[905, "CAM011"] +ca533.treeMean[905, 1] } \keyword{ manip } From noreply at r-forge.r-project.org Tue Jun 2 21:43:07 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 2 Jun 2015 21:43:07 +0200 (CEST) Subject: [Dplr-commits] r993 - in pkg/dplR: R man Message-ID: <20150602194307.50B75185B70@r-forge.r-project.org> Author: andybunn Date: 2015-06-02 21:43:07 +0200 (Tue, 02 Jun 2015) New Revision: 993 Modified: pkg/dplR/R/treeMean.R pkg/dplR/man/treeMean.Rd Log: In treeMean(), building on Mikko's last comment/commit: * Renamed first argument to 'x' (was already named so in the \arguments section of the .Rd file). I changed that to "rwl" to be consistent with other functions like detrend * Inputs are checked. Having treeMean run naively with no ids is probably a bad idea. I think rather than have ids=NULL be the default we should have it stop with no valid ids object. And yes, I think having the output be "rwl" class is a good idea. * A warning is produced if there are missing tree IDs, which is probably a rare occasion. The series with NA IDs are now averaged. Is this desirable or not? The resulting average may not be very useful. Prior to my changes, the function would return a completely NA-filled "average" for series with a missing tree ID. I think a stop here instead. * Default 'ids' is NULL, means one core per tree (no averaging). I think a stop here instead. * Row names of 'ids' (if any) are matched to column names of 'x'. Good. * Small optimizations were made. * Code and examples were reformatted a bit. * Note: Should the return value inherit class "rwl"? Yes. I think so. I looked through the help files for read.rwl etc and see that the value in the help file just indicates that a data.frame is returned. Should the help file say that the object is class "rwl" as well as "data.frame"? Modified: pkg/dplR/R/treeMean.R =================================================================== --- pkg/dplR/R/treeMean.R 2015-06-02 15:03:06 UTC (rev 992) +++ pkg/dplR/R/treeMean.R 2015-06-02 19:43:07 UTC (rev 993) @@ -1,39 +1,34 @@ -treeMean <- function(x, ids = NULL) { - ## If 'ids' is NULL then assume one core per tree (no averaging) - if (is.null(ids)) { - res <- as.data.frame(x) - names(res) <- seq_len(length(res)) - return(res) - } - x2 <- as.matrix(x) +treeMean <- function(rwl, ids) { + rwl2 <- as.matrix(rwl) if (!is.data.frame(ids) || !("tree" %in% names(ids))) { stop("'ids' must be a data.frame with column 'tree'") } - colnames.x <- colnames(x2) + colnames.rwl <- colnames(rwl2) trees <- as.matrix(ids["tree"]) rownames.ids <- rownames(trees) - ## If all column names in 'x' are present in the set of row + ## If all column names in 'rwl' are present in the set of row ## names in 'ids', arrange 'ids' to matching order - if (!is.null(rownames.ids) && !is.null(colnames.x) && - anyDuplicated(colnames.x) == 0 && - all(colnames.x %in% rownames.ids)) { - trees <- trees[colnames.x, ] - } else if (length(trees) == ncol(x2)) { + if (!is.null(rownames.ids) && !is.null(colnames.rwl) && + anyDuplicated(colnames.rwl) == 0 && + all(colnames.rwl %in% rownames.ids)) { + trees <- trees[colnames.rwl, ] + } else if (length(trees) == ncol(rwl2)) { trees <- as.vector(trees) } else { - stop("dimension problem: ", "'ncol(x)' != 'nrow(ids)'") + stop("dimension problem: ", "'ncol(rwl)' != 'nrow(ids)'") } uTrees <- unique(trees) if (any(is.na(uTrees))) { warning("series with missing tree IDs, will be averaged") } matches <- match(trees, uTrees) - res <- matrix(NA_real_, nrow=nrow(x2), ncol=length(uTrees)) + res <- matrix(NA_real_, nrow=nrow(rwl2), ncol=length(uTrees)) for (i in seq_along(uTrees)) { - res[, i] <- rowMeans(x2[, matches == i, drop=FALSE], na.rm=TRUE) + res[, i] <- rowMeans(rwl2[, matches == i, drop=FALSE], na.rm=TRUE) } res[is.nan(res)] <- NA_real_ - res <- as.data.frame(res, row.names = rownames(x2)) + res <- as.data.frame(res, row.names = rownames(rwl2)) names(res) <- uTrees + class(res) <- c("rwl", "data.frame") res } Modified: pkg/dplR/man/treeMean.Rd =================================================================== --- pkg/dplR/man/treeMean.Rd 2015-06-02 15:03:06 UTC (rev 992) +++ pkg/dplR/man/treeMean.Rd 2015-06-02 19:43:07 UTC (rev 993) @@ -6,18 +6,17 @@ This function calculates the mean value for each tree in a rwl or rwi object. } \usage{ -treeMean(x, ids = NULL) +treeMean(rwl, ids) } \arguments{ - \item{x}{a \code{data.frame} of ring widths with - \code{rownames(\var{x})} containing years and \code{colnames(x)} + \item{rwl}{a \code{data.frame} of ring widths with + \code{rownames(\var{rwl})} containing years and \code{colnames(rwl)} containing each series \acronym{ID} such as produced by \code{\link{read.rwl}}} - \item{ids}{ an optional \code{data.frame} with column one named + \item{ids}{ a \code{data.frame} with column one named \code{"tree"} giving a \code{numeric} \acronym{ID} for each tree and column two named \code{"core"} giving a \code{numeric} \acronym{ID} - for each core. Defaults to one core per tree as\cr - \code{data.frame(tree=1:ncol(\var{rwi}), core=rep(1, ncol(\var{rwi})))}. } + for each core. } } \details{ Here. @@ -26,7 +25,7 @@ A \code{data.frame} with the means of each tree. } -\author{ Andy Bunn. Patched and improved by Mikko Korpela. } +\author{ Andy Bunn. Patched and improved by Mikko Korpela. } \seealso{ \code{\link{read.rwl}}, \code{\link{read.ids}} } From noreply at r-forge.r-project.org Wed Jun 3 11:24:56 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 3 Jun 2015 11:24:56 +0200 (CEST) Subject: [Dplr-commits] r994 - in pkg/dplR: . R man Message-ID: <20150603092456.AF280187A47@r-forge.r-project.org> Author: mvkorpel Date: 2015-06-03 11:24:56 +0200 (Wed, 03 Jun 2015) New Revision: 994 Modified: pkg/dplR/DESCRIPTION pkg/dplR/R/treeMean.R pkg/dplR/man/read.compact.Rd pkg/dplR/man/read.fh.Rd pkg/dplR/man/read.rwl.Rd pkg/dplR/man/read.tucson.Rd pkg/dplR/man/treeMean.Rd Log: Changes as suggested by Andy: * Class of return value, c("rwl", "data.frame"), is documented where appropriate. * In treeMean(), stop() when missing tree IDs are detected. Modified: pkg/dplR/DESCRIPTION =================================================================== --- pkg/dplR/DESCRIPTION 2015-06-02 19:43:07 UTC (rev 993) +++ pkg/dplR/DESCRIPTION 2015-06-03 09:24:56 UTC (rev 994) @@ -3,7 +3,7 @@ Type: Package Title: Dendrochronology Program Library in R Version: 1.6.4 -Date: 2015-06-02 +Date: 2015-06-03 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", Modified: pkg/dplR/R/treeMean.R =================================================================== --- pkg/dplR/R/treeMean.R 2015-06-02 19:43:07 UTC (rev 993) +++ pkg/dplR/R/treeMean.R 2015-06-03 09:24:56 UTC (rev 994) @@ -19,7 +19,7 @@ } uTrees <- unique(trees) if (any(is.na(uTrees))) { - warning("series with missing tree IDs, will be averaged") + stop("missing tree IDs are not allowed") } matches <- match(trees, uTrees) res <- matrix(NA_real_, nrow=nrow(rwl2), ncol=length(uTrees)) Modified: pkg/dplR/man/read.compact.Rd =================================================================== --- pkg/dplR/man/read.compact.Rd 2015-06-02 19:43:07 UTC (rev 993) +++ pkg/dplR/man/read.compact.Rd 2015-06-03 09:24:56 UTC (rev 994) @@ -19,9 +19,9 @@ format. } \value{ - A \code{data.frame} with the series in columns and the years as - rows. The series \acronym{ID}s are the column names and the years are - the row names. + An object of class \code{c("rwl", "data.frame")} with the series in + columns and the years as rows. The series \acronym{ID}s are the + column names and the years are the row names. } \author{ Mikko Korpela } \seealso{ \code{\link{read.rwl}}, \code{\link{read.tucson}}, Modified: pkg/dplR/man/read.fh.Rd =================================================================== --- pkg/dplR/man/read.fh.Rd 2015-06-02 19:43:07 UTC (rev 993) +++ pkg/dplR/man/read.fh.Rd 2015-06-03 09:24:56 UTC (rev 994) @@ -19,10 +19,11 @@ Chronologies or half-chronos in fh-format are not supported. } \value{ - A \code{data.frame} with the series in columns and the years as rows. The - keycodes are the column names and the years are the row - names. Depending on metadata available in the input file, the - following attributes may be present in the \code{data.frame}: + An object of class \code{c("rwl", "data.frame")} with the series in + columns and the years as rows. The keycodes are the column names and + the years are the row names. Depending on metadata available in the + input file, the following attributes may be present in the + \code{data.frame}: \item{ids}{A \code{data.frame} identifying the series. Always contains columns \code{"tree"} and \code{"core"}, may contain columns Modified: pkg/dplR/man/read.rwl.Rd =================================================================== --- pkg/dplR/man/read.rwl.Rd 2015-06-02 19:43:07 UTC (rev 993) +++ pkg/dplR/man/read.rwl.Rd 2015-06-03 09:24:56 UTC (rev 994) @@ -30,10 +30,11 @@ read operation. } \value{ - If a \code{"tucson"} or \code{"compact"} file is read (even through - \code{"auto"}), returns a \code{data.frame} with the series in columns - and the years as rows. The series \acronym{ID}s are the column names - and the years are the row names. + If a \code{"tucson"}, \code{"compact"} or \code{"heidelberg"} file is + read (even through \code{"auto"}), returns an object of class + \code{c("rwl", "data.frame")} with the series in columns and the years + as rows. The series \acronym{ID}s are the column names and the years + are the row names. If a \code{"tridas"} file is read (even through \code{"auto"}), returns a list of results. See \code{\link{read.tridas}} for more Modified: pkg/dplR/man/read.tucson.Rd =================================================================== --- pkg/dplR/man/read.tucson.Rd 2015-06-02 19:43:07 UTC (rev 993) +++ pkg/dplR/man/read.tucson.Rd 2015-06-03 09:24:56 UTC (rev 994) @@ -40,9 +40,9 @@ formatting problems. } \value{ - A \code{data.frame} with the series in columns and the years as - rows. The series \acronym{ID}s are the column names and the years are - the row names. + An object of class \code{c("rwl", "data.frame")} with the series in + columns and the years as rows. The series \acronym{ID}s are the + column names and the years are the row names. } \author{ Andy Bunn. Patched and greatly improved by Mikko Korpela. } \seealso{ \code{\link{read.rwl}}, \code{\link{read.compact}}, Modified: pkg/dplR/man/treeMean.Rd =================================================================== --- pkg/dplR/man/treeMean.Rd 2015-06-02 19:43:07 UTC (rev 993) +++ pkg/dplR/man/treeMean.Rd 2015-06-03 09:24:56 UTC (rev 994) @@ -22,7 +22,8 @@ Here. } \value{ - A \code{data.frame} with the means of each tree. + An object of class \code{c("rwl", "data.frame")} with the means of + each tree. } \author{ Andy Bunn. Patched and improved by Mikko Korpela. } From noreply at r-forge.r-project.org Wed Jun 3 22:49:29 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 3 Jun 2015 22:49:29 +0200 (CEST) Subject: [Dplr-commits] r995 - pkg/dplR/man Message-ID: <20150603204929.8FDB7187948@r-forge.r-project.org> Author: andybunn Date: 2015-06-03 22:49:29 +0200 (Wed, 03 Jun 2015) New Revision: 995 Modified: pkg/dplR/man/treeMean.Rd Log: modified example to treeMean Modified: pkg/dplR/man/treeMean.Rd =================================================================== --- pkg/dplR/man/treeMean.Rd 2015-06-03 09:24:56 UTC (rev 994) +++ pkg/dplR/man/treeMean.Rd 2015-06-03 20:49:29 UTC (rev 995) @@ -34,6 +34,8 @@ data(gp.rwl) gp.ids <- read.ids(gp.rwl, stc = c(0, 2, 1)) gp.treeMean <- treeMean(gp.rwl, gp.ids) +# plot using S3method for class "rwl" +plot(gp.treeMean,plot.type="spag") data(ca533) ca533.treeMean <- treeMean(ca533, autoread.ids(ca533)) From noreply at r-forge.r-project.org Thu Jun 4 23:46:43 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 4 Jun 2015 23:46:43 +0200 (CEST) Subject: [Dplr-commits] r996 - in pkg/dplR: R man Message-ID: <20150604214643.9673D187881@r-forge.r-project.org> Author: andybunn Date: 2015-06-04 23:46:43 +0200 (Thu, 04 Jun 2015) New Revision: 996 Modified: pkg/dplR/R/treeMean.R pkg/dplR/man/treeMean.Rd Log: Added an argument to treeMean to limit averaging to a period with >1 core in cases where there are two more samples per tree. Just passing na.rm to rowMeans. Question: what to do if there is no overlap between two cores? E.g., core A runs from 1800 to 1850 and core B from 1852 to 2014. Sometimes (silly) users set their data up this way. This would make internal NA which is a bad practice. Modified: pkg/dplR/R/treeMean.R =================================================================== --- pkg/dplR/R/treeMean.R 2015-06-03 20:49:29 UTC (rev 995) +++ pkg/dplR/R/treeMean.R 2015-06-04 21:46:43 UTC (rev 996) @@ -1,4 +1,4 @@ -treeMean <- function(rwl, ids) { +treeMean <- function(rwl, ids, na.rm=FALSE) { rwl2 <- as.matrix(rwl) if (!is.data.frame(ids) || !("tree" %in% names(ids))) { stop("'ids' must be a data.frame with column 'tree'") @@ -24,7 +24,7 @@ matches <- match(trees, uTrees) res <- matrix(NA_real_, nrow=nrow(rwl2), ncol=length(uTrees)) for (i in seq_along(uTrees)) { - res[, i] <- rowMeans(rwl2[, matches == i, drop=FALSE], na.rm=TRUE) + res[,i] <- rowMeans(rwl2[, matches == i, drop=FALSE], na.rm=na.rm) } res[is.nan(res)] <- NA_real_ res <- as.data.frame(res, row.names = rownames(rwl2)) Modified: pkg/dplR/man/treeMean.Rd =================================================================== --- pkg/dplR/man/treeMean.Rd 2015-06-03 20:49:29 UTC (rev 995) +++ pkg/dplR/man/treeMean.Rd 2015-06-04 21:46:43 UTC (rev 996) @@ -6,7 +6,7 @@ This function calculates the mean value for each tree in a rwl or rwi object. } \usage{ -treeMean(rwl, ids) +treeMean(rwl, ids, na.rm=FALSE) } \arguments{ \item{rwl}{a \code{data.frame} of ring widths with @@ -17,13 +17,21 @@ \code{"tree"} giving a \code{numeric} \acronym{ID} for each tree and column two named \code{"core"} giving a \code{numeric} \acronym{ID} for each core. } + \item{na.rm}{ \code{logical} passed to \code{\link{rowMeans}}. Should + missing values be removed?} } \details{ - Here. + This function averages together multiple cores to give a mean value of growth. + It is very common in dendrochronology to take more than one core per tree. In + those cases it is occassionally desirable to have an average of the cores. + This function merely loops through the \code{rwl} object and calculates the + \code{\link{rowMeans}} for each tree. If \code{na.rm=TRUE} trees with >1 + sample will be averaged only over the period where the samples overlap. + If FALSE the output can vary in the number of samples. See examples. } \value{ - An object of class \code{c("rwl", "data.frame")} with the means of - each tree. + An object of class \code{c("rwl", "data.frame")} with the mean annual value + for each tree. } \author{ Andy Bunn. Patched and improved by Mikko Korpela. } @@ -33,20 +41,21 @@ \examples{ data(gp.rwl) gp.ids <- read.ids(gp.rwl, stc = c(0, 2, 1)) + gp.treeMean <- treeMean(gp.rwl, gp.ids) -# plot using S3method for class "rwl" -plot(gp.treeMean,plot.type="spag") +gp.treeMean2 <- treeMean(gp.rwl, gp.ids, na.rm=TRUE) +# look at an example of a single tree with different averaging periods +tree40 <- data.frame(gp.rwl[, c("40A","40B")], + gp.treeMean[, "40", drop=FALSE], + gp.treeMean2[, "40", drop=FALSE]) +names(tree40) <- c("coreA", "coreB", "treeMean1", "treeMean2") +head(tree40,50) + data(ca533) ca533.treeMean <- treeMean(ca533, autoread.ids(ca533)) -# look at an example of two cores per tree -tail(ca533[, c("CAM031", "CAM032"), drop=FALSE]) -tail(rowMeans(ca533[, c("CAM031", "CAM032"), drop=FALSE], na.rm=TRUE)) -tail(ca533.treeMean[, "3", drop=FALSE]) -# look at an example of single tree -ca533[, "CAM011", drop=FALSE] -ca533.treeMean[, 1] -ca533[905, "CAM011"] -ca533.treeMean[905, 1] +# plot using S3method for class "rwl" +plot(ca533.treeMean,plot.type="spag") + } \keyword{ manip }