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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jul 17 02:58:52 CEST 2012


Author: weylandt
Date: 2012-07-17 02:58:52 +0200 (Tue, 17 Jul 2012)
New Revision: 681

Added:
   pkg/xtsExtra/R/zzz.R
Modified:
   pkg/xtsExtra/R/plot.R
Log:
Don't use assignInMyNamespace() so we can use R <= 2.14

Modified: pkg/xtsExtra/R/plot.R
===================================================================
--- pkg/xtsExtra/R/plot.R	2012-07-12 23:57:40 UTC (rev 680)
+++ pkg/xtsExtra/R/plot.R	2012-07-17 00:58:52 UTC (rev 681)
@@ -236,7 +236,7 @@
   # Would like to use do.call and as.list so pro-users can pass widths and heights
   # to layout -- currently undocumented behavior
   # do.call("layout", as.list(layout.screens)) 
-  layout(layout.screens)
+  if(length(layout.screens) > 1L) layout(layout.screens)
   
   have_x_axis <- logical(length(levels(screens)))
   for(i in seq_len(NROW(layout.screens))){
@@ -396,12 +396,12 @@
                         minor.ticks, major.format, auto.grid, 
                         candles, events, blocks, ylab.loc, ...){
   
-  if(QUANTMOD_MESSAGE) {
+  if(exists(".QUANTMOD_MESSAGE", .GlobalEnv) && get(".QUANTMOD_MESSAGE", .GlobalEnv)) {
     message("Note that CRAN Package quantmod provides much better OHLC charting.\n",
             "This message will show once per session.")
-    assignInMyNamespace("QUANTMOD_MESSAGE",FALSE) 
-    # Is there a better way to do this ? 
-    # I'd think lexical scoping but I get a locked binding error
+    # Help page says not to use assignInMyNamespace() so we'll do it manually in .GlobalEnv
+    # Also, it was only introduced in R 2.15 so probably better to remove it
+    assign(".QUANTMOD_MESSAGE", FALSE, envir = .GlobalEnv)
   }
   
   # Extract OHLC Columns and order them
@@ -441,5 +441,3 @@
     get.elm.recycle(split(rep(if(length(levels(screens)) == 1L) list(dots[[par]]) else dots[[par]],
      length.out = length(screens)), screens), n)
 }
-
-QUANTMOD_MESSAGE <- TRUE # Suggests quantmod to user of OHLC plot.xts

Added: pkg/xtsExtra/R/zzz.R
===================================================================
--- pkg/xtsExtra/R/zzz.R	                        (rev 0)
+++ pkg/xtsExtra/R/zzz.R	2012-07-17 00:58:52 UTC (rev 681)
@@ -0,0 +1,4 @@
+.onAttach <- function(...){
+  # Suggests quantmod to user of OHLC plot.xts
+  assign(".QUANTMOD_MESSAGE", TRUE, .GlobalEnv)
+}



More information about the Xts-commits mailing list