[Dplr-commits] r771 - in pkg/dplR: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Apr 6 05:50:42 CEST 2014


Author: andybunn
Date: 2014-04-06 05:50:39 +0200 (Sun, 06 Apr 2014)
New Revision: 771

Modified:
   pkg/dplR/ChangeLog
   pkg/dplR/DESCRIPTION
   pkg/dplR/NAMESPACE
   pkg/dplR/R/rwl.stats.R
   pkg/dplR/TODO
   pkg/dplR/man/rwl.stats.Rd
Log:
Added summary S3 method for rwl objects (calls rwl.stats). But, the Rd file needs some configuring - do we really need dots in the usage section?

Modified: pkg/dplR/ChangeLog
===================================================================
--- pkg/dplR/ChangeLog	2014-04-05 18:17:20 UTC (rev 770)
+++ pkg/dplR/ChangeLog	2014-04-06 03:50:39 UTC (rev 771)
@@ -4,6 +4,18 @@
 -------------------------
 - Added a TODO list. This is exciting.
 
+File: NAMESPACE
+-------------------------
+- Added chron.plot to export list.
+- Added rho.series to export list.
+- Added plot.rwl as an S3Method.
+- Added summary.rwl as an S3Method.
+
+File: rwl.stats
+-------------------------
+- Added an S3 summary method for rwl objects so that summary(an rwl object)
+  calls rwl.stats()
+
 Folder: vignettes
 -------------------------
 - Added a vignettes folder
@@ -16,12 +28,6 @@
 -------------------------
 - A vignette to intriduce dplR
 
-File: NAMESPACE
--------------------------
-- Added chron.plot to export list.
-- Added rho.series to export list.
-- Added plot.rwl as an S3Method.
-
 File: corr.rwl.seg.R
 --------------------
 - Removed yr.range() function in favor of yr.range() in helpers.R.
@@ -29,10 +35,7 @@
 
 File: series.rho.R
 -------------------------
-- New function series.rho. This needs more work.
-  E.g., speed up via apply()? And need to integrate
-  into rwl.stats WITHOUT any new arguments being
-  added to rwl.stats. I like that function clean.
+- New function series.rho.
 
 File: read.compact.R
 -------------------------
@@ -69,12 +72,7 @@
 
 File: rwl.plot.R
 -------------------------
-- New wrapper to plot rwl objects. This is setting the
-  stage for having plot, summary, etc. methods for rwl
-  objects. There are still several things to work on. Like
-  setting the class() of rwl data objects via read.rwl (and in
-  the onboard data sets). And will this class change break any
-  existing functions?
+- New wrapper to plot rwl objects.
 
 File: spag.plot.R
 -------------------------

Modified: pkg/dplR/DESCRIPTION
===================================================================
--- pkg/dplR/DESCRIPTION	2014-04-05 18:17:20 UTC (rev 770)
+++ pkg/dplR/DESCRIPTION	2014-04-06 03:50:39 UTC (rev 771)
@@ -3,7 +3,7 @@
 Type: Package
 Title: Dendrochronology Program Library in R
 Version: 1.6.0
-Date: 2014-04-04
+Date: 2014-04-05
 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",
@@ -26,5 +26,5 @@
         analyses, IO, and graphics.
 LazyData: no
 License: GPL (>= 2)
-URL: http://www.wwu.edu/huxley/treering/dplR.shtml,
+URL: http://huxley.wwu.edu/trl/htrl-dplr,
         http://R-Forge.R-project.org/projects/dplr/

Modified: pkg/dplR/NAMESPACE
===================================================================
--- pkg/dplR/NAMESPACE	2014-04-05 18:17:20 UTC (rev 770)
+++ pkg/dplR/NAMESPACE	2014-04-06 03:50:39 UTC (rev 771)
@@ -36,7 +36,8 @@
        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, series.rho)
+       write.tucson, chron.plot, plot.rwl, series.rho, summary.rwl)
 
 S3method(print, redfit)
 S3method(plot, rwl)
+S3method(summary, rwl)
\ No newline at end of file

Modified: pkg/dplR/R/rwl.stats.R
===================================================================
--- pkg/dplR/R/rwl.stats.R	2014-04-05 18:17:20 UTC (rev 770)
+++ pkg/dplR/R/rwl.stats.R	2014-04-06 03:50:39 UTC (rev 771)
@@ -1,5 +1,7 @@
+`summary.rwl` <- function(object,...){ rwl.stats(object) }
+
 `rwl.stats` <-
-    function(rwl)
+    function(object)
 {
     acf1 <- function(x){
         ar1 <- acf(x[!is.na(x)], lag.max=1, plot=FALSE)
@@ -10,20 +12,20 @@
         sum((y-mean(y))^3) / (length(y)*sd(y)^3)
     }
 
-    yr <- as.numeric(row.names(rwl))
-    series.stats <- data.frame(series=names(rwl))
-    the.range <- as.matrix(apply(rwl, 2, yr.range, yr.vec=yr))
+    yr <- as.numeric(row.names(object))
+    series.stats <- data.frame(series=names(object))
+    the.range <- as.matrix(apply(object, 2, yr.range, yr.vec=yr))
     series.stats$first <- the.range[1, ]
     series.stats$last <- the.range[2, ]
     series.stats$year <- series.stats$last - series.stats$first + 1
-    series.stats$mean <- colMeans(rwl, na.rm=TRUE)
-    series.stats$median <- apply(rwl, 2, median, na.rm=TRUE)
-    series.stats$stdev <- apply(rwl, 2, sd, na.rm=TRUE)
-    series.stats$skew <- apply(rwl, 2, skew)
-    series.stats$sens1 <- apply(rwl, 2, sens1)
-    series.stats$sens2 <- apply(rwl, 2, sens2)
-    series.stats$gini <- apply(rwl, 2, gini.coef)
-    series.stats$ar1 <- apply(rwl, 2, acf1)
+    series.stats$mean <- colMeans(object, na.rm=TRUE)
+    series.stats$median <- apply(object, 2, median, na.rm=TRUE)
+    series.stats$stdev <- apply(object, 2, sd, na.rm=TRUE)
+    series.stats$skew <- apply(object, 2, skew)
+    series.stats$sens1 <- apply(object, 2, sens1)
+    series.stats$sens2 <- apply(object, 2, sens2)
+    series.stats$gini <- apply(object, 2, gini.coef)
+    series.stats$ar1 <- apply(object, 2, acf1)
     seq.temp <- -seq_len(4)
     series.stats[, seq.temp] <- round(series.stats[, seq.temp], 3)
 

Modified: pkg/dplR/TODO
===================================================================
--- pkg/dplR/TODO	2014-04-05 18:17:20 UTC (rev 770)
+++ pkg/dplR/TODO	2014-04-06 03:50:39 UTC (rev 771)
@@ -1,3 +1,8 @@
+o [mvkorpel] Look at Rd page for rwl.stats. Is there a way to not include
+  dots as an argument to summary.rwl? The function rwl.stats() doesn't use
+  dots. But I can't leave them out of the \usage section or R CMD check 
+  complains.
+
 o [mvkorpel] Fix the sty file so that Sweave code adheres to the margins. And
   what is the best way to make the figure widths take up the text width?
   In addition to my many other failings, I'm not great at LaTeX!
@@ -7,13 +12,11 @@
   I've been compiling the vignettes in Rstudio which leaves a lot of junk
   behind when it's done.
 
-* Make an S3 summary method for rwl objects that calls rwl.stats.
-
 * Improve the help file for series.rho.
 
 * Decide when to use class('rwl') in functions dealing with rwl objects.
-  Other than the plot S3Method for rwl, are there cases when having that class
-  would be useful. E.g., in error checking?
+  Other than the plot and summary S3Method for rwl, are there cases when 
+  having that class would be useful. E.g., in error checking?
 
 - Consider the benefits and drawbacks of creating classes for chonologies. 
   One benefit would be an S3 plot method for chronologies.

Modified: pkg/dplR/man/rwl.stats.Rd
===================================================================
--- pkg/dplR/man/rwl.stats.Rd	2014-04-05 18:17:20 UTC (rev 770)
+++ pkg/dplR/man/rwl.stats.Rd	2014-04-06 03:50:39 UTC (rev 771)
@@ -1,20 +1,27 @@
 \name{rwl.stats}
 \alias{rwl.stats}
-\title{ Calculate Descriptive Statistics on Ring-Width Series }
+\alias{summary.rwl}
+\title{ Calculate Descriptive Summary Statistics on Ring-Width Series }
 \description{
-  This function calculates descriptive statistics on a \code{data.frame}
+  This function calculates descriptive statistics on a \code{rwl} object
   of raw or detrended ring-width series.
 }
 \usage{
-rwl.stats(rwl)
+rwl.stats(object)
+
+\method{summary}{rwl}(object,...)
+
 }
 \arguments{
-  \item{rwl}{ a \code{data.frame} with (usually) raw ring-width series
+  \item{object}{ a \code{rwl} object with (usually) raw ring-width series
   as columns and years as rows such as that produced by
   \code{\link{read.rwl}}.  It is sometimes desirable to run this on
-  detrended (e.g., rwi) data particularly for the sensitivity measures
-  (\code{\link{sens1}}, \code{\link{sens2}}, \code{\link{gini.coef}}). }
+  detrended (e.g., rwi) data. }
+
+  \item{\dots}{ Additional arguemnts for summary.default. Does this have
+  to be here? If this item is not included, R CMD check gives a warning. }
 }
+
 \details{
   This calculates a variety of descriptive statistics commonly used in
   dendrochronology (see below). Users unfamiliar with these should see
@@ -44,5 +51,6 @@
 \seealso{ \code{\link{rwi.stats}}, \code{\link{read.rwl}} }
 \examples{data(ca533)
 rwl.stats(ca533)
+summary(ca533)
 }
 \keyword{ misc }



More information about the Dplr-commits mailing list