[Dplr-commits] r952 - in pkg/dplR: . R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jan 28 14:41:45 CET 2015
Author: mvkorpel
Date: 2015-01-28 14:41:44 +0100 (Wed, 28 Jan 2015)
New Revision: 952
Modified:
pkg/dplR/ChangeLog
pkg/dplR/DESCRIPTION
pkg/dplR/NAMESPACE
pkg/dplR/R/net.R
pkg/dplR/R/pointer.R
pkg/dplR/R/rwl.stats.R
Log:
New imported package "matrixStats". Using its functions to speed up
operations on the rows or columns of matrices, e.g. colMedians(),
rowSds(). For example, the mean running time (on a particular
computer) of net(ca533.rwi) as in ?net dropped from about 30
milliseconds to less than 6 milliseconds (measured with the
"microbenchmark" package).
Modified: pkg/dplR/ChangeLog
===================================================================
--- pkg/dplR/ChangeLog 2015-01-22 09:21:27 UTC (rev 951)
+++ pkg/dplR/ChangeLog 2015-01-28 13:41:44 UTC (rev 952)
@@ -11,7 +11,7 @@
- A new field, MailingList, shows the address of the web interface
to the dplR-help mailing list hosted on Google Groups.
-- New Imported package: R.utils.
+- New Imported packages: Matrix, matrixStats, R.utils.
- New Suggested package: testthat. Unit tests are now done with testthat
instead of RUnit.
- RUnit is no longer Suggested.
@@ -26,6 +26,7 @@
- Importing captureOutput() from R.utils.
- Importing package Matrix.
+- Importing various functions from matrixStats.
- Exporting net().
Various .R files
@@ -36,6 +37,8 @@
the $bins matrix in the return value of ccf.series.rwl(),
corr.rwl.seg(), and corr.series.seg() does not have (undocumented)
column names anymore.
+- Using functions from the matrixStats package to speed up some
+ operations on the rows or columns of matrices.
File: ffcsaps.R
---------------
Modified: pkg/dplR/DESCRIPTION
===================================================================
--- pkg/dplR/DESCRIPTION 2015-01-22 09:21:27 UTC (rev 951)
+++ pkg/dplR/DESCRIPTION 2015-01-28 13:41:44 UTC (rev 952)
@@ -3,7 +3,7 @@
Type: Package
Title: Dendrochronology Program Library in R
Version: 1.6.3
-Date: 2015-01-22
+Date: 2015-01-28
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",
@@ -19,9 +19,9 @@
Maintainer: Andy Bunn <andy.bunn at wwu.edu>
Depends: R (>= 2.15.2)
Imports: graphics, grDevices, grid, stats, utils, lattice (>= 0.13-6),
- Matrix (>= 1.0-3), digest (>= 0.2.3), gmp (>= 0.5-5), png (>=
- 0.1-1), R.utils (>= 1.32.0), stringi (>= 0.2-2), stringr (>=
- 0.4), XML (>= 2.1-0)
+ Matrix (>= 1.0-3), digest (>= 0.2.3), gmp (>= 0.5-5),
+ matrixStats (>= 0.9.7), png (>= 0.1-1), R.utils (>= 1.32.0),
+ stringi (>= 0.2-2), stringr (>= 0.4), XML (>= 2.1-0)
Suggests: Biobase, dichromat (>= 1.2-3), foreach, forecast, iterators,
knitr, RColorBrewer, testthat (>= 0.8), tikzDevice, waveslim
Description: This package contains functions for performing tree-ring
Modified: pkg/dplR/NAMESPACE
===================================================================
--- pkg/dplR/NAMESPACE 2015-01-22 09:21:27 UTC (rev 951)
+++ pkg/dplR/NAMESPACE 2015-01-28 13:41:44 UTC (rev 952)
@@ -20,6 +20,8 @@
importFrom(lattice, panel.abline, panel.dotplot, panel.segments,
trellis.par.set, xyplot)
+importFrom(matrixStats, colMedians, colSds, rowSds)
+
importFrom(png, readPNG)
importFrom(R.utils, captureOutput)
Modified: pkg/dplR/R/net.R
===================================================================
--- pkg/dplR/R/net.R 2015-01-22 09:21:27 UTC (rev 951)
+++ pkg/dplR/R/net.R 2015-01-28 13:41:44 UTC (rev 952)
@@ -14,7 +14,7 @@
}
## Standard deviation standardized by mean
variability <- function(mat) {
- Sd <- apply(mat, 1, sd, na.rm = TRUE)
+ Sd <- rowSds(mat, na.rm = TRUE)
Mean <- rowMeans(mat, na.rm = TRUE)
Sd / Mean
}
Modified: pkg/dplR/R/pointer.R
===================================================================
--- pkg/dplR/R/pointer.R 2015-01-22 09:21:27 UTC (rev 951)
+++ pkg/dplR/R/pointer.R 2015-01-28 13:41:44 UTC (rev 952)
@@ -40,7 +40,7 @@
nat.y.2 <- pmax(0, out[, 4] - (nseries.thresh - 0.0000001))
out[, 5] <- sign(nat.y.1 - nat.y.2)
out[, 6] <- (rowMeans(gv, na.rm=TRUE) - 1) * 100
- out[, 7] <- apply(gv, 1, function(x) sd(x, na.rm=TRUE)) * 100
+ out[, 7] <- rowSds(gv, na.rm=TRUE) * 100
if (is.numeric(round.decimals) && length(round.decimals) > 0 &&
is.finite(round.decimals[1]) && round.decimals[1] >= 0) {
for (i in c(3, 4, 6, 7)) {
Modified: pkg/dplR/R/rwl.stats.R
===================================================================
--- pkg/dplR/R/rwl.stats.R 2015-01-22 09:21:27 UTC (rev 951)
+++ pkg/dplR/R/rwl.stats.R 2015-01-28 13:41:44 UTC (rev 952)
@@ -14,18 +14,19 @@
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))
+ rwl2 <- as.matrix(rwl)
+ the.range <- as.matrix(apply(rwl2, 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(rwl2, na.rm=TRUE)
+ series.stats$median <- colMedians(rwl2, na.rm=TRUE)
+ series.stats$stdev <- colSds(rwl2, na.rm=TRUE)
+ series.stats$skew <- apply(rwl2, 2, skew)
+ series.stats$sens1 <- apply(rwl2, 2, sens1)
+ series.stats$sens2 <- apply(rwl2, 2, sens2)
+ series.stats$gini <- apply(rwl2, 2, gini.coef)
+ series.stats$ar1 <- apply(rwl2, 2, acf1)
seq.temp <- -seq_len(4)
series.stats[, seq.temp] <- round(series.stats[, seq.temp], 3)
More information about the Dplr-commits
mailing list