In the spirit of improving the reproducibility of my workflow, I'm trying to figure out the best way to save session information for reports or bookdown books in which it is not desirable to include the session info in the final project.
A few considerations:
I would like to save the session information in human readable format. Since both sessionInfo() and devtools::session_info() output lists, it's not obvious how to save or nicely display this information. For saving, the best option I've found is to use capture.output() per this SO answer. For printing, changing the options() width setting is the only thing I've found to make the package list look nice. Seems like a prime candidate for a tidy() method...
Would best practices be affected by the output type: whether I'm running an R script, knitting an .Rmd file to html_document, or creating a bookdown book?
Would best practices be affected by whether I'm, say, rendering a bookdown book locally vs. by Travis?
How should rmarkdown caching be handled? Does the installation of new packages break the cache? If not, which I'm guessing is the case, then the session info is not accurate for cached chunks.
I haven't seen enough on this topic to suggest a best practice. I have a few suggestions.
You can create a session object, such as
demo.Rmd_session_2019_11_15 <- sessionInfo()
Obviously this works best with version control, such as git.
You can format following the reprex below
library(pander)
library(sessioninfo)
demo.Rmd_session_2019_11_15 <- session_info()
pander(demo.Rmd_session_2019_11_15)
#> Warning in pander.default(demo.Rmd_session_2019_11_15): No pander.method for
#> "session_info", reverting to default.
#> Warning in pander.default(x[[i]], indent = indent + 1): No pander.method for
#> "platform_info", reverting to default.