[Quantmod-commits] r615 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Dec 7 19:24:02 CET 2014


Author: bodanker
Date: 2014-12-07 19:24:02 +0100 (Sun, 07 Dec 2014)
New Revision: 615

Modified:
   pkg/R/newTA.R
Log:
- Revert r613 and use Brian Riply's better solution of explicitly setting
  the environment of the function being returned


Modified: pkg/R/newTA.R
===================================================================
--- pkg/R/newTA.R	2014-11-27 18:31:50 UTC (rev 614)
+++ pkg/R/newTA.R	2014-12-07 18:24:02 UTC (rev 615)
@@ -94,14 +94,14 @@
   .body[5] <- paste("x <-",funToFun(FUN,FUN.name,data.at, dots=fdots))
   if(.body[6] == 'postFUN <- ""') .body[6] <- ''
   if(.body[4] == 'preFUN <- ""' ) .body[4] <- ''
-  as.function(c(.formals,as.call(parse(text=.body))[[1]]),.GlobalEnv) 
+  as.function(c(.formals,as.call(parse(text=.body))[[1]]),
+              envir = asNamespace('quantmod'))
 }
 
+## Do not edit!  Some line numbers are referred to in newTA.
 `skeleton.TA` <- function(on)
 {
-    # need explicit access to quantmod:::get.current.chob()
-    # so the function returned by newTA can access it
-    lchob <- quantmod:::get.current.chob()
+    lchob <- get.current.chob()
     x <- as.matrix(lchob at xdata)
     preFUN  <- ""
     FUN     <- ""
@@ -122,6 +122,7 @@
     chobTA at call <- match.call()
     legend.name <- gsub('^add','',deparse(match.call()))
     gpars <- list()
+    ## safe to edit from here down
     chobTA at params <- list(xrange = lchob at xrange, yrange=yrange, colors = lchob at colors, 
         color.vol = lchob at color.vol, multi.col = lchob at multi.col, 
         spacing = lchob at spacing, width = lchob at width, bp = lchob at bp, 
@@ -132,10 +133,7 @@
         lchob at passed.args$TA <- c(TA, chobTA)
         lchob at windows <- lchob at windows + ifelse(chobTA at new, 1, 
             0)
-        # need explicit access to quantmod:::chartSeries.chob
-        # so the function returned by newTA can access it
-        chartSeries.chob <- quantmod:::chartSeries.chob
-        do.call('chartSeries.chob',list(lchob))
+        do.call(chartSeries.chob,list(lchob))
         invisible(chobTA)
     }
     else {



More information about the Quantmod-commits mailing list