install node.js
node.js is available here
add the directory to your path
install GitBook
use the following command to install GitBook.
npm install gitbook -g
install GitBook PDF Generator
npm install gitbook-pdf -g
install GitBook R package
devtools::install_github("jbryer/gitbook")
verify that Gitbook is installed
library(gitbook)
checkForGitbook()
create a new Gitbook
newGitbook("test")
initial the GitBook
The initGitbook function will create the files and folders for your book. This function will change the file extensions of all your files to .Rmd
initGitbook()
buid the .md files
The buildRmd function will convert all .Rmd files in your project to .md using the knitr package.
buildRmd()
build the GitBooks
use format to specify the format of the built book. Options are gitbook (default website book), pdf, or ebook.
(PDF format is not so beautiful and can not add figures.)
# buildGitbook(format='pdf')
buildGitbook()
open your built book
The openGitbook will open your built book using your system’s default web browser.
openGitbook()
publish your built Gitbook to GitHub
publishGitbook(repo = "test")