quantmod - ploting multiple objects from a function in R -



quantmod - ploting multiple objects from a function in R -

i'm trying function chart quantmod chart , rect's on top. it's working fine when running cmd when wrapping within function either rect showing , or graph showing, or neither showing. illustration 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) } you might need run plot.new() if homecoming chart object function , print it, works haven't found way of returning both chart object , rect's (the rect list well) i understand functions work in temporary environment - haven't found way of running function in global env. don't know how assign rect chob in global env. the function plotting - want add together more lines, labels etc'.

thanks.

if wrap chart_series() within print seems 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()

r quantmod

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -