Set current subtitle

I cannot set the current subtitle for the add_TA function (quantmod package).

curon = 2

add_TA(x, type = "l",col = "blue", lwd = 2, on=curon)

(add line to subtitle 2)

R gives me this error:

Error in plot_ta(x = current.chob(), ta = get("x"), on = curon, taType = NULL,  : 
 object 'curon' not found.

team:

add_TA(x, type = "l",col = "blue", lwd = 2, on=2) 

working fine though.

NOTE. The problem only occurs when used in a function, and not in a global scope. Here is a complete example:

library(quantmod)

test=function(){
x=xts(runif(10),Sys.Date()+1:10)
z=1/x
chart_Series(x)
add_TA(x, type = "l",col = "green", lwd = 2)    #OK
add_TA(z, type = "l",col = "blue", lwd = 2, on=2)   #OK
curon = 2;add_TA(z, type = "l",col = "red", lwd = 2, on=curon)  #FAILS
}

test()
+3
source share
1 answer

I think you must have a typo in the code that you did not show since it works for me:

library(quantmod)
x=xts(runif(10),Sys.Date()+1:10)
z=1/x

chart_Series(x)
add_TA(x, type = "l",col = "green", lwd = 2)
curon = 2
add_TA(z, type = "l",col = "blue", lwd = 2, on=curon)

(By the way, this is what people mean by a โ€œfully reproducible minimal exampleโ€, that you can copy and paste into a new session R. If this is not important for your question, the data may be random.)

: , ( , , , ). on curon, :

library(quantmod)

test=function(){
x=xts(runif(10),Sys.Date()+1:10)
z=1/x
chart_Series(x)
add_TA(x, type = "l",col = "green", lwd = 2) 
on=2;add_TA(z, type = "l",col = "blue", lwd = 2, on=on)
}
+3

All Articles