2
votes

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

1 Answers

1
votes

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)