wflow_convert
converts existing R Markdown files to use the workflowr
template. This is especially useful when migrating an existing project with
many R Markdown files to use workflowr.
wflow_convert(files, standalone = FALSE, dry_run = FALSE, verbose = TRUE)
files | character. The R Markdown file(s) to be converted. Must have file extension Rmd or rmd. Supports file globbing. |
---|---|
standalone | logical (default: FALSE). Embed the configuration chunks directly in the document to create a standalone file. Should only need to be used when creating files outside the context of a workflowr project. |
dry_run | logical (default: FALSE). Preview the changes to the files.
Show the output of |
verbose | logical (default: TRUE). Report progress. |
Invisibly returns a list which contains the results of running
diff
between the original and converted versions of each file. The
names of the list elements are the filenames. The diffs are character
vectors. Only files which were successfully converted are included.
wflow_convert
attempts to identify the current state of each R
Markdown file and convert it to the latest version of the workflowr template.
Specifically, it can perform any of the following conversions:
Convert a standard R Markdown file to use the workflowr template
Convert an outdated workflowr Rmd file to use the latest workflowr template
Convert a workflowr Rmd file to the standalone version of the template
(if standalone = TRUE
)
Convert a standalone workflowr Rmd file to the non-standalone version
of the template (if standalone = FALSE
)
Convert an ashlar R Markdown file to use the workflwor template
If a given R Markdown file is already using the latest version of the template, it is not changed.
If a file is lacking a YAML header, a generic YAML header is added.
wflow_convert
overwrites the original files.
not_run({ # Convert an R Markdown file to use workflowr template wflow_convert("existing.Rmd") # Convert an R Markdown file to use workflowr template, # but embed the shared chunks to create a standalone file wflow_convert("existing.Rmd", standalone = TRUE) # Preview the changes wflow_convert("existing.Rmd", dry_run = TRUE) # Convert multiple an R Markdown files wflow_convert(files = list.files(path = "analysis", pattern = "Rmd$", full.names = TRUE)) })