[英]Save a Sweave PDF output using custom file name
I have a sweave code that is producing a pdf. 我有一个生成PDF的Sweave代码。 The code works fine.
该代码工作正常。 I run it from the command line using:"
我使用以下命令从命令行运行它:
R CMD Sweave --pdf filename.Rnw
The resulting pdf that is produced is save in the working directory as 生成的结果pdf将另存为工作目录
filename.pdf
filename.pdf
Instead I would like 2 things: 相反,我想要两件事:
I tried using suggestions from here: Attach date to PDF generated with Sweave but that didn't work. 我尝试从这里使用建议: 将日期附加到使用Sweave生成的PDF中,但这没有用。 Needless to say it could be because I am absolutely new to R/SWEAVE and suck?
不用说这可能是因为我绝对不熟悉R / SWEAVE吗?
I don't think that can be done on the command line, but you can do it if you run Sweave within R: 我认为无法在命令行上完成此操作,但是如果在R中运行Sweave,则可以执行此操作:
filename <- paste0("wrk/random/dir/filename", format(Sys.Date(), "%d%m%Y"), ".tex")
Sweave("filename.Rnw", output=filename)
tools::texi2pdf(filename)
You could put this in a *.R file and run it with Rscript
if you don't want to start R. 如果不想启动R,可以将其放在* .R文件中,并使用
Rscript
运行它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.