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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Apr 28 12:47:23 CEST 2014


Author: mvkorpel
Date: 2014-04-28 12:47:23 +0200 (Mon, 28 Apr 2014)
New Revision: 842

Modified:
   pkg/dplR/ChangeLog
   pkg/dplR/R/common.interval.R
Log:
Bug fix in plotting code of common.interval()

Modified: pkg/dplR/ChangeLog
===================================================================
--- pkg/dplR/ChangeLog	2014-04-28 08:49:19 UTC (rev 841)
+++ pkg/dplR/ChangeLog	2014-04-28 10:47:23 UTC (rev 842)
@@ -1,5 +1,11 @@
 * CHANGES IN dplR VERSION 1.6.1
 
+File: common.interval.R
+-----------------------
+
+- Bug fix: make.plot=TRUE threw an error when input data.frame had leading
+  or trailing all-NA rows
+
 * CHANGES IN dplR VERSION 1.6.0
 
 File: TODO

Modified: pkg/dplR/R/common.interval.R
===================================================================
--- pkg/dplR/R/common.interval.R	2014-04-28 08:49:19 UTC (rev 841)
+++ pkg/dplR/R/common.interval.R	2014-04-28 10:47:23 UTC (rev 842)
@@ -162,19 +162,21 @@
             first.year <- series.range[1, ]
 
             neworder <- sort.list(first.year, na.last = TRUE)
-            rwl.first <- first.year[neworder[1]]
-            if (is.na(rwl.first)) {
-                if (yrs.ordered) {
-                    rwl.first <- yrs[1]
-                    rwl.last <- yrs[nRow.rwl]
-                } else {
-                    rwl.first <- min(yrs)
-                    rwl.last <- max(yrs)
-                }
+            if (yrs.ordered) {
+                rwl.first <- yrs[1]
+                rwl.last <- yrs[nRow.rwl]
             } else {
-                rwl.last <- max(series.range[2, ], na.rm = TRUE)
+                rwl.first <- min(yrs)
+                rwl.last <- max(yrs)
             }
-            plot(1, 1, type = "n", xlim = c(rwl.first, rwl.last + 1),
+            plot.first <- first.year[neworder[1]]
+            if (is.na(plot.first)) {
+                plot.first <- rwl.first
+                plot.last <- rwl.last
+            } else {
+                plot.last <- max(series.range[2, ], na.rm = TRUE)
+            }
+            plot(1, 1, type = "n", xlim = c(plot.first, plot.last + 1),
                  ylim = c(1, nCol.rwl), axes = FALSE, ylab = "",
                  xlab = gettext("Year", domain = "R-dplR"))
             rwl.seq <- seq(from = rwl.first, to = rwl.last + 1, by = 0.5)



More information about the Dplr-commits mailing list