【问题标题】:R run sweave (Rnw) file from an R scriptR 从 R 脚本运行 sweave (Rnw) 文件
【发布时间】:2016-12-06 18:10:41
【问题描述】:

我想从 R 脚本运行 sweave。 Rnw 文件位于我的项目目录下方的 Rnw 目录中。我试过这个

system("Rnw/compilePDF.Rnw")

得到了这个回复。

sh: Rnw/compilePDF.Rnw: Permission denied

.Rnw 文件的权限是 -rw-r--r-- 但我怀疑这不是问题。

【问题讨论】:

    标签: r sweave


    【解决方案1】:

    解决方案是包含以下代码。需要编码,因为 Sweave 默认为 ASCII 并为此返回错误。

    Sweave("Rnw/compilePDF.Rnw", encoding = "UTF-8")
    

    命令的输出是

    Writing to file compilePDF.tex
    Processing code chunks with options ...
    
    You can now run (pdf)latex on ‘compilePDF.tex’
    

    要将其转换为 pdf,请使用

    tools::texi2pdf("Rnw/compilePDF.tex")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-07
      • 1970-01-01
      • 2016-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-04
      相关资源
      最近更新 更多