This function strives to provide a standardized way to convert all relevant
.Rmd files in the
Rmd/ subdirectory to bare
.R files in the
knitr::purl(). It is mainly intended for authoring R packages in the R Markdown file format.
purl_rmd( path = ".", add_copyright_notice = pal::pkg_config_val(key = "add_copyright_notice", pkg = this_pkg, default = TRUE), add_license_notice = pal::pkg_config_val(key = "add_license_notice", pkg = this_pkg, default = TRUE), gen_pkgdown_ref = pal::pkg_config_val(key = "gen_pkgdown_ref", pkg = this_pkg, default = TRUE) )
Path to the root of the package directory.
Whether or not to add a copyright notice at the beginning of the generated
Whether or not to add a license notice at the beginning of the generated
Whether or not to overwrite pkgdown's reference index in the configuration file
.R files will be named the same as the
.Rmd files plus the suffix
.gen to indicate the file was auto-generated. So the file
Rmd/foo.Rmd for example will be converted to
The R Markdown file format allows you to intermingle code with related prose in Markdown syntax optimized for human readability. This facilitates (best) practices which are commonly referred to as literate programming.
In practice, the main advantage of writing R code in R Markdown is that you don't have to rely on
# comments to explain, annotate or otherwise elaborate on your code. It also
allows you to easily compile your source code to beautifully looking HTML, PDF etc. files using
purl_rmd() does not generate an
.R file for each and every R Markdown file in the
Rmd/ subdirectory. Two types of
.Rmd files are excluded from
Files having the suffix
.nopurl in their name, e.g.
Hidden files as per Unix convention whose names start
with a dot, e.g.
The above convention allows for easy exclusion of specific
.Rmd files from purling. A common case for this are scripts that generate package-internal data from raw sources. Such a script could be stored as
Rmd/data.nopurl.Rmd, so that no corresponding file
R/*.R is generated. For the sake of clarity, it's generally advised to prefer the
.nopurl suffix over hiding files.