Skip to content

Latest commit

 

History

History
78 lines (53 loc) · 3.69 KB

README_bookdown-howto.md

File metadata and controls

78 lines (53 loc) · 3.69 KB

README

There are multiple methods for creating a bookdown. This template enables a streamlined approach where the bookdown template has been overlayed into an RStudio Project which is also a Git repository.

Bookdown

Bookdown is an open source R package that makes it easy to write books. It works really well within the RStudio project environment and is the preferred method within the Duke Stats department for producing and submitting honors theses.

Procedures

  1. Update/install: R/RStudio. This workshop assumes you have Git installed.

  2. Update/install tidyverse, bookdown, tinytex. Then install TinyTex distribution

install.packages(c("tidyverse", "bookdown", "tinytex"))
tinytex::install_tinytex()   
  1. Clone your customized GitHub repository (https://github.com/DukeStatSci)
  2. Create a test Bookdown Book: Build tab > Build Book button. Your test book should build without errors
  3. Develop your analysis; compose and orchestrate your HTML book. Ignore PDF for now

Tips

  1. In bookdown, each chapter is an Rmd file found in the project root. (index.Rmd [required], 01, 02, ... 999999)
  2. Files and directory names that begin with underscore _ will not be processed by bookdown::render_book()
  3. Cannot have identical code-chunk names
  4. Code chunks that produce visualizations should have a code chunk name
  5. Synchronize the file_name for each chapter with HEADER 1: #, line 1
  6. Cannot have identical identifiers for chapters and sections. Can have custom identifiers {#foo-identifier}
  7. Merge and Knit or Knit and Merge
  8. Your compiled book is in the _book directory. You may put _book and other directories into .gitignore

In Workshop

  1. Open index.Rmd and Knit a single page

    • Note YAML metadata (title, author, bibliography, etc.)
    • See LaTeX in the end of line 16
    • _output.yml controls the TOC header/footer. Lines 1 & 10 identify the gitbook and PDF outputs
  2. book.bib

    • Copy/Paste one of the entries. Edit the identifier (i.e. the first line of the copied bib entry), the author, and the title
    • Tools like Zotero can generate a .bib file
  3. 45-tables_are_fun.Rmd

    • line 54: Reference the new citation you created in step 2
    • line 61: LaTeX $$ or $
    • line 5 & 37: uncomment library(gt) and change eval=TRUE
  4. Build > Build Book will generate the whole gitbook and the PDF derivative

  5. _bookdown.yml: Optionally, you can edit the book_filename. "_main" is the default

  6. As time allows make a new chapter (e.g. Visualization) and display a plot without code



license: “CC BY-NC”

Creative Commons: Attribution, Non-Commerical
https://creativecommons.org/licenses/by-nc/4.0/

References