[Dplr-commits] r954 - pkg/dplR/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jan 28 17:05:48 CET 2015


Author: mvkorpel
Date: 2015-01-28 17:05:48 +0100 (Wed, 28 Jan 2015)
New Revision: 954

Modified:
   pkg/dplR/R/i.detrend.series.R
   pkg/dplR/R/read.crn.R
   pkg/dplR/R/rwi.stats.running.R
   pkg/dplR/R/series.rwl.plot.R
   pkg/dplR/R/wc.to.po.R
Log:
More matrix stats optimizations

Modified: pkg/dplR/R/i.detrend.series.R
===================================================================
--- pkg/dplR/R/i.detrend.series.R	2015-01-28 14:12:54 UTC (rev 953)
+++ pkg/dplR/R/i.detrend.series.R	2015-01-28 16:05:48 UTC (rev 954)
@@ -4,7 +4,7 @@
     fits <- detrend.series(y, y.name, make.plot=TRUE, nyrs = nyrs, f = f,
                            pos.slope = pos.slope)
     ## Remove the nec resids if all na
-    fits <- fits[, !apply(is.na(fits), 2, all), drop=FALSE]
+    fits <- fits[, !colAlls(is.na(fits)), drop=FALSE]
     col.names <- names(fits)
     cat(gettextf("\nChoose a detrending method for this series %s.\n",
                  y.name, domain="R-dplR"))

Modified: pkg/dplR/R/read.crn.R
===================================================================
--- pkg/dplR/R/read.crn.R	2015-01-28 14:12:54 UTC (rev 953)
+++ pkg/dplR/R/read.crn.R	2015-01-28 16:05:48 UTC (rev 954)
@@ -118,7 +118,7 @@
     ## Clean up NAs
     crn.mat[which(crn.mat[, -ncol.crn.mat] == 9990)] <- NA # column-major order
     crn.mat <-
-        crn.mat[!apply(is.na(crn.mat[, -ncol.crn.mat, drop=FALSE]), 1, all),
+        crn.mat[!rowAlls(is.na(crn.mat[, -ncol.crn.mat, drop=FALSE])),
                 ,
                 drop=FALSE]
     ## If samp depth is all 1 then dump it

Modified: pkg/dplR/R/rwi.stats.running.R
===================================================================
--- pkg/dplR/R/rwi.stats.running.R	2015-01-28 14:12:54 UTC (rev 953)
+++ pkg/dplR/R/rwi.stats.running.R	2015-01-28 16:05:48 UTC (rev 954)
@@ -167,13 +167,13 @@
     tree.any <- matrix(FALSE, n.years, n.trees)
     for (i in seq.tree) {
         tree.any[, i] <-
-            apply(rwiNotNA[, treeIds == unique.trees[i], drop=FALSE], 1, any)
+            rowAnys(rwiNotNA[, treeIds == unique.trees[i], drop=FALSE])
     }
     n.trees.by.year <- rowSums(tree.any)
 
     ## Easy way to force complete overlap of data
     if (period2 == "common") {
-        bad.rows <- !apply(rwiNotNA, 1, all)
+        bad.rows <- !rowAlls(rwiNotNA)
         rwi3[bad.rows, ] <- NA
         rwiNotNA[bad.rows, ] <- FALSE
         good.rows.flag <- !bad.rows
@@ -305,8 +305,7 @@
             rbar.bt <- rsum.bt / n.bt
         }
 
-        coresPresent <-
-            which(apply(rwiNotNA[year.idx, , drop = FALSE], 2, any))
+        coresPresent <- which(colAnys(rwiNotNA[year.idx, , drop = FALSE]))
         treesPresent <- unique(treeIds[coresPresent])
         nCores <- length(coresPresent)
         nTrees <- length(treesPresent)

Modified: pkg/dplR/R/series.rwl.plot.R
===================================================================
--- pkg/dplR/R/series.rwl.plot.R	2015-01-28 14:12:54 UTC (rev 953)
+++ pkg/dplR/R/series.rwl.plot.R	2015-01-28 16:05:48 UTC (rev 954)
@@ -20,7 +20,7 @@
 
     seg.lag <- seg.length / 2
 
-    mask <- !apply(as.matrix(is.na(rwl2)), 1, all)
+    mask <- !rowAlls(as.matrix(is.na(rwl2)))
     yrs0 <- as.numeric(row.names(rwl2))[mask]
     ## Normalize.
     tmp <- normalize.xdate(rwl2, series2, n, prewhiten, biweight)

Modified: pkg/dplR/R/wc.to.po.R
===================================================================
--- pkg/dplR/R/wc.to.po.R	2015-01-28 14:12:54 UTC (rev 953)
+++ pkg/dplR/R/wc.to.po.R	2015-01-28 16:05:48 UTC (rev 954)
@@ -15,10 +15,8 @@
                     !is.na(missing))
     pith.offset <- rep(as.integer(NA), n)
     pith.offset[not.na] <-
-        as.integer(apply(cbind(missing[not.na], unmeasured[not.na]),
-                         1,
-                         sum,
-                         na.rm = TRUE) + 1)
+        as.integer(rowSums(cbind(missing[not.na], unmeasured[not.na]),
+                           na.rm = TRUE) + 1)
 
     data.frame(series = row.names(wc),
                pith.offset)



More information about the Dplr-commits mailing list