- Make sure you have installed
bookdown
. This can be done in one of two ways,
install.packages("bookdown")
# or the development version
devtools::install_github("rstudio/bookdown")
- Create an
.Rmd
file in the root of the project. Make sure to name it using "snake_case" style. - Add the content to your file.
- Add the name of your file to the
rmd_files:
section of the_bookdown.yml
file, which is located in the root of the project. The position of the name of your file in this section determines the order in which your file will be rendered and, subsequently, the number of the chapter. Make sure to add a comma "," after the name. Right now, thermd_files:
section of the_bookdown.yml
file looks like this,
rmd_files: [
"index.Rmd",
"intro.Rmd",
"references.Rmd",
]
- Render your your chapter and/or the whole book.
#preview just one chapter
file <- "intro.Rmd" # Chapter to preview
bookdown::render_book(file, "bookdown::gitbook",
preview = TRUE)
# render the whole book
bookdown::render_book("index.Rmd",
"bookdown::gitbook")
You can also use the helper file render_book.R
in the R/
folder of project to execute the code above.