i'm trying to a function to chart a quantmod
chart and some rect's on top. it's working fine when running from the cmd but when wrapping inside a function either only the rect are showing , or only the graph is showing, or sometimes neither is showing.
Example code :
f1 <- function() {
require(quantmod)
s <- get(getSymbols('PRGO'))["2012::"]
chart_Series(s)
u<-par("usr")
d<-data.frame(Buttom=c(100,90),Top=c(110,95))
rect(u[1],d[,'Buttom'],u[2],d[,'Top'],col=rgb(1,0,0,alpha=0.2),border=0)
}
assign
the rect to the chob
in the global env.Thanks.
If you wrap your chart_Series()
inside a print
it seems to work ?
f1 <- function() {
require(quantmod)
s <- get(getSymbols('PRGO'))["2012::"]
print(chart_Series(s))
u<-par("usr")
d<-data.frame(Buttom=c(100,90),Top=c(110,95))
rect(u[1],d[,'Buttom'],u[2],d[,'Top'],col=rgb(1,0,0,alpha=0.2),border=0)
}
f1()