Skip to contents

Predefined litr templates make it easy to get started writing R packages of various kinds. The following table shows the litr::draft* functions that can be used to create a litr .Rmd file from template. Click on the “Generated html” and “Generated R package” cells to see what each template produces.

Function Description Rmd source file Generated html Generated R package
draft() the most basic package: a function and a test create-rhello.Rmd create-rhello.html rhello/
draft_data() a package with a data set in it create-rhasdata.Rmd create-rhasdata.html rhasdata/
draft_rcpp() a package using Rcpp create-withrcpp.Rmd create-withrcpp.html withrcpp/
draft_extras() a package with a README, vignette(s), a pkgdown site, and a hex sticker create-withpkgdown.Rmd create-withpkgdown.html withpkgdown/
draft_bookdown() a package defined in a bookdown index.Rmd, 1description.Rmd, …, 4end.Rmd _book/index.html frombookdown/
draft_armadillo() a package using RcppArmadillo create-witharmadillo.Rmd create-witharmadillo.html witharmadillo/

Once you’ve chosen a template, you can get started by calling the corresponding litr::draft* function from the table above.

For example, for the most basic template, you would do the following:

litr::draft("rhello")
litr::render("create-rhello.Rmd")

And to make an R package that uses Rcpp, you would start with the following:

litr::draft_rcpp("withrcpp")
litr::render("create-withrcpp.Rmd")