[texhax] include a pdf graphics file whose name includes a varying date
Christopher W Ryan
cryan at binghamton.edu
Fri Oct 14 20:19:52 CEST 2016
I am using R and Sweave and MikTeX on Windows 7. I use this workflow
to generate a recurring report quarterly. Same report, just new data.
The R code generates a graph, saving it as a pdf file, the filename
including the date. Each time I run the report, I want to include the
most current graph. How would I do that?
Example code (just excerpts, does not actually compile, but I think it
will convey my intent):
<<timeseriesplot, results=hide, echo=FALSE>>=
# make the major graph
pdf(file=paste("NaloxoneUseEMS-timeseriesplot-", Sys.Date(), ".pdf",
sep=""), height=8, width=12)
## bunch of R code in here to create a graph
dev.off()
@
The later in the file, I have:
\begin{figure}\centering
\includegraphics{NaloxoneUseEMS-timeseriesplot-2016-08-04}
\end{figure}
^^^^^^^^^^^^^
here is the problem
How do I make this
part of the figure filename
increment to match SysDate()
from R in the code chunk above?
I understand I could just include the code-generating chunk inside a
Sweave environment with fig=TRUE, but I have some reasons for
preferring to save the graph as a pdf file and use it later.
Thanks.
--Chris Ryan
More information about the texhax
mailing list