Attach date to PDF generated with Sweave

旧巷老猫 提交于 2019-12-13 16:19:39

问题


I generate via Sweave a daily report. I would like to attach to the PDF´s name the current date in the format YYYYMMDD. I am using the following code to generate the file:

rnwfile <- system.file("Sweave", "Margin.Rnw", package = "utils")
Sweave(rnwfile)
tools::texi2pdf("Margin.tex")

Margin.Rnw is my master copy of the report I want to generate (mixing LaTeX with R code). The output I get is a the file Margin.pdf. I would like instead to have a file named *Margin_YYYYMMDD.pdf*. I would appreciate if you have any advise.


回答1:


See the output argument to ?RweaveLatex.

This is untested but should (?) work:

rnwfile <- system.file("Sweave", "Margin.Rnw", package = "utils")
outfn <- paste0("Margin_",format(Sys.time(),"%Y%m%d"),".tex")
Sweave(rnwfile,output=outfn)
tools::texi2pdf(outfn)


来源:https://stackoverflow.com/questions/13346979/attach-date-to-pdf-generated-with-sweave

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!