litr R package
May 27, 2022
This document uses literate programming to define the
litr R package. This means that all source code for
litr is contained and presented in this document alongside explanation. The
litr R package gets created as an output when one runs a piece of code that takes this document as input. To modify the
litr package, one should modify the code in this document (and the explanation, as needed) and then regenerate the package. But what piece of code do we use to create an R package from this document?
Well… it turns out that this is precisely what the
litr package is for. But how can we use
litr to create
litr? We actually use version \(n-1\) of
litr to create version \(n\). When an R markdown file is rendered with
litr, an R package is created in addition to the usual html/pdf/etc document. To learn more about using
litr, please visit the litr website. This document is not intended for people who wish to use
litr. Rather, it is intended for people who want to know how it works and (possibly) modify it.
This document used
litr version 0.9.0 to define the current version of
litr. In particular, it was generated by running the following command in an R console from the working directory containing
litr::render("index.Rmd") fs::dir_copy("_book", "../docs/create", overwrite = TRUE) fs::dir_delete("_book")
The second and third lines move the generated bookdown to the
docs/ directory so that it will render nicely on github by visiting https://jacobbien.github.io/litr-project/create/.