[Dplr-commits] r953 - in pkg/dplR: . R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jan 28 15:12:54 CET 2015
Author: mvkorpel
Date: 2015-01-28 15:12:54 +0100 (Wed, 28 Jan 2015)
New Revision: 953
Modified:
pkg/dplR/NAMESPACE
pkg/dplR/R/common.interval.R
Log:
matrixStats speedup for common.interval()
Modified: pkg/dplR/NAMESPACE
===================================================================
--- pkg/dplR/NAMESPACE 2015-01-28 13:41:44 UTC (rev 952)
+++ pkg/dplR/NAMESPACE 2015-01-28 14:12:54 UTC (rev 953)
@@ -20,7 +20,8 @@
importFrom(lattice, panel.abline, panel.dotplot, panel.segments,
trellis.par.set, xyplot)
-importFrom(matrixStats, colMedians, colSds, rowSds)
+importFrom(matrixStats, colAlls, colAnys, colMedians, colSds, rowAlls,
+ rowSds)
importFrom(png, readPNG)
Modified: pkg/dplR/R/common.interval.R
===================================================================
--- pkg/dplR/R/common.interval.R 2015-01-28 13:41:44 UTC (rev 952)
+++ pkg/dplR/R/common.interval.R 2015-01-28 14:12:54 UTC (rev 953)
@@ -24,7 +24,7 @@
## series with overlaps
rm.short <- function(rwl, yrs, rwlNotNA, row.idx, flag=FALSE) {
n <- 0
- anyNotNA <- apply(rwlNotNA, 2, any)
+ anyNotNA <- colAnys(rwlNotNA)
which.good <- which(anyNotNA)
nCol.orig <- length(which.good)
series.range <- matrix(NA_real_, 2, nCol.orig)
@@ -55,7 +55,7 @@
break
}
}
- tmp <- apply(rwlNotNA[dontkeep.row, keep.col, drop = FALSE], 1, all)
+ tmp <- rowAlls(rwlNotNA[dontkeep.row, keep.col, drop = FALSE])
dontkeep.row[dontkeep.row] <- !tmp
nRow <- nRow + sum(tmp)
n.years <- nCol * nRow
@@ -133,7 +133,7 @@
keep.row <- tmp[[3]]
keep.col <- tmp[[4]]
} else { # type2 == "both"
- keep.col <- apply(rwlNotNA[row.idx, , drop = FALSE], 2, all)
+ keep.col <- colAlls(rwlNotNA[row.idx, , drop = FALSE])
nCol <- sum(keep.col)
}
opt <- nRow * nCol
More information about the Dplr-commits
mailing list