My personal favourite R
templates for doing reproducible data analyses.
From CRAN:
Note that the template example reports use the libraries DT, ggplot2 and xfun, so you will to install them if you want to see a working example.
Once the templates are installed, you can use them in 2 ways:
File
> New File
> R Markdown...
> From Template
.create_rtemp()
function which allows you to create a new directory with all the template files inside, ready to be used/rendered.rtemps::create_rtemp(dirname = "new-dir", template = "united_html")
rmarkdown::render(input = "new-dir/index.Rmd", output_format = "html_document", output_dir = "new-dir")
index.Rmd
inside the created directory. Only then the RStudio IDE will understand the format and create the build Tool
option when you create a project inside the newly created directory.Of course, you can always just use the build_book.sh
script to render the book directly as in the commands below (for Linux users):
Rscript -e "rtemps::create_rtemp(dirname = 'new-dir', template = 'bookdown_lite')"
cd new-dir
./build_book.sh
Rscript -e "bookdown::render_book(input = 'index.Rmd', output_format = 'bookdown::gitbook')"
For Windows users, simply execute the previous commands inside an R session:
rtemps::create_rtemp(dirname = 'new-dir', template = 'bookdown_lite')
cd new-dir # or the Windows equivalent :)
bookdown::render_book(input = 'index.Rmd', output_format = 'bookdown::gitbook')
The last command is inside the provided build_book.sh
file.
docs
directory, so that it can easily be rendered with GitHub Pages.split_by
property in the _output.yml
template file (check the doc).