0

Afternoon everyone.

We use rmarkdown from within Rstudio to write technical reports. These reports rely on external ascii (usually) datafiles which are read into dataframes and manipulated.

We also use RCS for version control as it gives us nice sequential numbering of report versions (1.1, 1.2 etc), date of checkin, author revision etc using the RCS variables.

Our problem is that if we have an Rmd file which calls in a bunch of other data files, and the datafiles change (for example, our QA department find a typo in a datafile which is changed), if we check in the Rmd file, nothing will change version control wise because the Rmd file itself hasn't changed, only files which it is dependant on.

We know we could ask users to run "ci -f" (to force a checkin) but they are so used to using the standard RCS command ("ci -l", "co -l" etc) that I'm fairly certain they would forget to add "-f".

Is there some way to have rstudio add a date/time tag into the YAML block each time the file is knitted ? If that worked then when the lab tech came to produce a new version of the report, once they had knitted it to preview and were ready to generate the final report, we know that the Rmd file would be checked in and the version control info increased/updated.

We have been wondering about using a Makefile of course, but that would involve building a list of dependencies of the external datafiles, and that is non trivial (datafiles may be dispersed throughout different directories in a project, and may not have their full pathname in the Rmd file if a function is doing the hard lifting, so we may have some cases where we parsed a file and couldn't find the dependencies).

Whilst I appreciate that forcing the file to change each time you knit it is a sledgehammer to crack a nut, it may be an interim solution for us.

Any thoughts much appreciated.
Pete

PJP
  • 612
  • 1
  • 6
  • 18
  • You are not limited to the YAML block. You can have an "backtick-r" expression anywhere to store a time stamp. Sweave already had that feature; many of my vignettes use it, and knitr supports it too. – Dirk Eddelbuettel Jan 16 '17 at 16:38
  • Di Dirk - unless I've completely misunderstood, the backticks only get interpreted when producing the output - they don't affect the Rmd file itself ? I need (would like!) something that makes rstudio/knitr add something the to the source Rmd file. – PJP Jan 16 '17 at 21:22
  • That is *completely* external. You could use a Makefile to 'stamp' your source. – Dirk Eddelbuettel Jan 16 '17 at 21:25
  • Your problem is that you want a _source_ file to be an _intermediary_ (== processed) file. To get there, you could start with a genuine source file, process it to add the date and then proceed. Otherwise the term "source file" pretty implied "will not be altered". – Dirk Eddelbuettel Jan 16 '17 at 21:42

0 Answers0