【问题标题】:R output to screen errorR输出到屏幕错误
【发布时间】:2017-06-29 04:16:52
【问题描述】:

我得到 Rscript 错误:

dev.copy2pdf(file = fname, out.type = "pdf") 中的错误: 只能从屏幕设备打印 执行停止

我在我的 Mac OSX 控制台中运行以下 R 源代码:

Rscript --vanulla charts.R

我使用的是 R 版本 3.3.2。这是我的来源:

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()

如果我想输出在 conole 上运行的 PDF,如何修复 dev.copy2pdf()。它在我的 RStudio 中运行良好, 谢谢

【问题讨论】:

    标签: r output


    【解决方案1】:

    这似乎已经解决了它

    #https://stackoverflow.com/questions/5625394/problem-saving-pdf-file-in-r-with-ggplot2
    pdf(fname)
    chartSeries(d, name=sym, theme="white",bar.type='ohlc',line.type="l",TA="addRSI();addVo();addBBands();addSMA()",subset='last 6 months')
    dev.off()
    

    【讨论】:

    • 解释一下具体方法会很有帮助:不要在编译图之后使用dev.copy2pdf()dev.print(),而是在之前使用pdf()
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-05
    • 2011-09-02
    • 1970-01-01
    • 2016-11-27
    • 1970-01-01
    • 2012-03-23
    • 1970-01-01
    相关资源
    最近更新 更多