【发布时间】: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。 Rnw 文件位于我的项目目录下方的 Rnw 目录中。我试过这个
system("Rnw/compilePDF.Rnw")
得到了这个回复。
sh: Rnw/compilePDF.Rnw: Permission denied
.Rnw 文件的权限是 -rw-r--r-- 但我怀疑这不是问题。
【问题讨论】:
解决方案是包含以下代码。需要编码,因为 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")
【讨论】: