I get Rscript error of:
Error in dev.copy2pdf(file = fname, out.type = "pdf") : can only print from a screen device Execution halted
I am running the following R source in my Mac OSX console with:
Rscript --vanulla charts.R
I am using R version 3.3.2. Here is my source:
library(quantmod)
sym <- 'IBM'
d <- getSymbols(sym,src = "yahoo", auto.assign = FALSE)
chartSeries(d, name = sym, theme = "white", bar.type = 'ohlc',
line.type = "l",TA = "addVo();addSMA()",
subset = 'last 6 months')
addRSI()
dev <- dev.prev()
fname <- sprintf("%s.pdf",sym)
dev.copy2pdf(file = fname, out.type = "pdf")
dev.off()
How do I fix the dev.copy2pdf()
if I want to output a PDF running on the conole. It runs fine within my RStudio,
Thanks