Chapter 12 Books
We have introduced the basics of R Markdown in Chapter 3, which highlighted how HTML, PDF, and Word documents can be produced from an R workflow. However, larger projects can become difficult to manage in a single R Markdown file. The bookdown package (Xie 2016, 2018) addresses this limitation, and offers several key improvements:
Books and reports can be built from multiple R Markdown files.
Additional formatting features are added, such as cross-referencing, and numbering of figures, equations, and tables.
Documents can easily be exported in a range of formats suitable for publishing, including PDF, e-books and HTML websites.
This book itself was created using bookdown, and acts as an example of what can be achieved. Despite the name containing the word “book”, bookdown is not only for books, and it can be used for long reports, dissertations, or even single R Markdown documents (see Section 12.4.4). It also works with other computing languages such as Python and C++ (see Section 2.7). If you want, you can even write documents irrelevant to computing, such as a novel.
In this chapter, we cover the basics of bookdown, and explain how to start a bookdown project. Much of the the content is based on the work “bookdown: Authoring Books and Technical Documents with R Markdown” (https://bookdown.org/yihui/bookdown/) of Xie (2016), which provides more detailed explanations of the concepts highlighted.