E Appendix E: The bookdown package

This entire html site was built using the bookdown R package. It has advanced features for building reports around analysis as you can see. The bookdown manual was itself written with the bookdown package. I uploaded the entire file structure to my git repository so you can build this bookdown website yourself. To do production builds I click on Build/Build All in RStudio, which starts up a new R session, compiles all the R code, aggregates tables and figures and creates both html and pdf versions. I have been running this code each evening since UM stopped face-to-face instruction in order to download and rerun the entire website with the newest data. I also added some conditional statements throughout to produce (almost automatically) two versions of this document: one version with the R code displayed with all the relevant R instructional material and one version without the R coding distraction.

To facilitate debugging and working on individual chapters, I used the special command bookdown::serve_book(in_session=T), which runs all the Rmd files locally in my session so I have all the R objects available in my R session, and can display the new version on a browser every time I save the Rmd file I’m working on. Sometimes to debug I may have to run R chunks manually to get the data set to the point at which the error occurs. To help quickly running Rmd files earlier in the sequence to get me to the place where the error occurs, I can run the command xaringan::inf_mr() for each Rmd file (make the Rmd file active in the RStudio editor before running inf_mr()). One needs to be careful not to start up multiple serve sessions when using this approach.