-
Notifications
You must be signed in to change notification settings - Fork 0
Bookdown
Thomas J. Brailey edited this page Jun 8, 2020
·
8 revisions
- Bookdown is an R package that allows to create articles, dissertations, and books in R.
- Bookdown's infrastructure is similar to Blogdown, so those who have made their own websites with R/Hugo/Blogdown will be familiar with the mix of .Rmd, .yml, and .html files, as well as the overall project structure.
- More specifically: most of the files in the Bookdown project needn't be worried about. There is a .travis.yml, _output.yml and _bookdown.yml file, and _build.sh and _deploy.sh file, and style and toc .css files. The rest of the files in the project are optional: the .Rmds, any BibTeX files, and so on.
- The writing portion of Bookdown takes place in an .Rmd file, and any analysis and relevant outputs go inside an R chunk.
- There are several packages that are well integrated into the Bookdown infrastructure.
-
knitr::kableandkableExtra::allow you to integrate LaTeX and html tables with R. See here for a guide on producing tables in R markdown files.
-
- Also mentioned in the tables guide, the package DT allows for interactive tables when exporting your Bookdown project to html.
- Of course,
ggplot2objects and other visualization packages can be easily formatted in .Rmd and Bookdown.
-
knitr::kableandkableExtra::are super useful when creating tabulated literature reviews, as these packages work well with both the Bookdown format and BibTeX. Here is the workflow for generating summary literature reviews:- In a Google Sheet/Excel Sheet, create a table that contains columns for the BibTeX citations, and other salient information (i.e. authors, exact date, datasets used, main arguments, issues with paper, relationships with other articles, summary statistics, and the like). Note that the BibTeX citation should take the format [@AuthorTitleTitleTitleYear].
- Read this sheet into your .Rmd file in your Bookdown project.
- Make any necessary adjustments using
tidyverse. - Use
kableandkableExtrato print the table when the .Rmd is compiled. - The BibTeX citations will now link to a full citation of the article in the references section of the .Rmd.
- One of the biggest issues with the Bookdown workflow is having to manually knit each chapter. If these chapters have a lot of analysis, plots, text, citations, and so on, knitting can take a long time. This makes the task of manually tweaking aesthetics and other small changes fairly inefficient. Additionally, issues may arise if one doesn't rerun the index file in the Bookdown project prior to rerunning the whole project. Again, this makes the process of updating the project to fix minor tweaks quite frustrating.
- One option is to open the knitted .Rmd file in a Google Chrome tab, and then as you save your work in R, you can refresh the Chrome tab to see updates to that particular file rather than knitting the whole thing from scratch.
- Another option is to start by writing the .Rmd files individually and then, once they are finished, save them into the Bookdown project. Then you can compile the whole project.
- Rex Douglass's guide to Covid-19 data is a great example of combining Bookdown with all the packages we have mentioned in this Wiki page.
- Follow this link: How to be Careful with Covid-19 Counts: A Practical Guide for Data Scientists
- Bookdown GitHub - clone to your personal computer and create your own books!
- Authoring books in Bookdown - a step-by-step guide on how to create a high quality book or manuscript in R.
- Bookdown video - for those who are audio and visual learners.