This text was created using the Bookdown package for R Markdown. R Markdown is a variant of the simple Markdown format created by John Gruber. That is to say, at its core this text is a series of simple text-files marked up with simple markers of syntax like
# marks to indicate headings and so on. R Markdown allows us to embed code snippets within the text that an interpreter, like R Studio, knows how to run, such that the results of the calculations become embedded in the surrounding discussion! This is a key part of making research more open and more reproducible, and which you’ll learn more about in chapter one.
The sequence of steps to produce a Bookdown-powered site looks like this:
- create a new project in RStudio (we typically create a new project in a brand new folder)
- run the following script to install Bookdown:
- create a new textfile with
metadatathat describe how the book will be built. The metadata is in a format called
YAML(‘yet another markup language’) that uses keys and values that get passed into other parts of Bookdown:
title: "The archaeology of spoons" author: "Graham, Gupta, Carter, & Compton" date: "July 1 2017" description: "A book about cocleararchaeology." github-repo: "my-github-account/my-project" cover-image: "images/cover.png" url: 'https\://my-domain-ex/my-project/' bibliography: myproject.bib biblio-style: apa-like link-citations: yes
This is the only thing you need to have in this file, which is saved in the project folder as
Write! We write the content of this book as text files, saving the parts in order. Each file should be numbered
03-the-spoons-of-site-x.Rmdand so on.
Build the book. With Bookdown installed, there will be a ‘Build Book’ button in the R Studio build pane. This will generate the static html files for the book, the pdf, and the epub. All of these will be found in a new folder in your project,
_book. There are many more customizations that can be done, but that is sufficient to get one started.