[Xts-commits] r731 - pkg/xtsExtra/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Sep 27 18:38:43 CEST 2012


Author: weylandt
Date: 2012-09-27 18:38:43 +0200 (Thu, 27 Sep 2012)
New Revision: 731

Modified:
   pkg/xtsExtra/R/plot.R
Log:
range(x) --> range(x, na.rm = TRUE) in ylim calculations

Modified: pkg/xtsExtra/R/plot.R
===================================================================
--- pkg/xtsExtra/R/plot.R	2012-09-21 15:19:41 UTC (rev 730)
+++ pkg/xtsExtra/R/plot.R	2012-09-27 16:38:43 UTC (rev 731)
@@ -189,8 +189,8 @@
   
   xy <- xy.coords(xy[,1L], xy[,2L])
   
-  if(missing(xlim)) xlim <- range(xy$x[is.finite(xy$x)])
-  if(missing(ylim)) ylim <- range(xy$y[is.finite(xy$y)])
+  if(missing(xlim)) xlim <- range(xy$x[is.finite(xy$x)], na.rm = TRUE)
+  if(missing(ylim)) ylim <- range(xy$y[is.finite(xy$y)], na.rm = TRUE)
 
   do.lab <- if(is.logical(xy.labels)) xy.labels else TRUE
 
@@ -300,14 +300,14 @@
   if(length(levels(screens)) == 1L && yax.loc != "none") par(oma = c(1,1,4,1))
   
   if(identical(ylim,'fixed')){
-    ylim <- list(range(x))
+    ylim <- list(range(x, na.rm = TRUE))
   } else if(identical(ylim, 'auto')){
     if(yax.loc == "none") {
       ylim <- lapply((1:NROW(layout.screens))[!duplicated(layout.screens)], function(y) {
-        do.call(range,split.xts.by.cols(x, screens)[layout.screens[y,]])
-      })
+        do.call(range,
+                list(split.xts.by.cols(x, screens)[layout.screens[y,]], na.rm = TRUE))})
     } else {
-      ylim <- lapply(split.xts.by.cols(x, screens), range)
+      ylim <- lapply(split.xts.by.cols(x, screens), function(x) range(x, na.rm = TRUE))
     }
   } else{
     if(!is.matrix(ylim)) dim(ylim) <- c(1L, NROW(ylim))
@@ -463,7 +463,7 @@
     assign(".QUANTMOD_MESSAGE", FALSE, envir = .GlobalEnv)
   }
   
-  if(identical(ylim, 'auto') || identical(ylim, 'fixed')) ylim <- range(x)
+  if(identical(ylim, 'auto') || identical(ylim, 'fixed')) ylim <- range(x, na.rm = TRUE)
   
   # Extract OHLC Columns and order them
   x <- x[,xts:::has.OHLC(x, TRUE)] 



More information about the Xts-commits mailing list