
Convert Knitr Chunk Headers in R Markdown Files
Source:R/48_convert_knitr_chunk_header.R
convert_knitr_chunk_header.RdConverts legacy knitr chunk headers in R Markdown (.Rmd) files to the
current header syntax using knitr::convert_chunk_header().
When path points to an R package root (a directory containing a
DESCRIPTION file), the conversion is applied to all .Rmd files found
under the package vignettes/ directory (including subdirectories) and to
the package README.Rmd file when present.
When path points to a single file, that file is converted and written
back in place.
Arguments
- path
Path to an R package root directory or an R Markdown file. If
NULL(the default), the current working directory is used.- ...
Additional arguments passed to
knitr::convert_chunk_header().
Examples
tmp <- tempfile(fileext = ".Rmd")
writeLines(c("```{r, echo=TRUE, fig.width=10}", "x <- 1", "```"), tmp)
convert_knitr_chunk_header(tmp)
#> ℹ Converting knitr chunk headers in /tmp/RtmpEsKggO/file19a46ad3a40e.Rmd
readLines(tmp)
#> [1] "```{r}" "#| echo = TRUE," "#| fig.width = 10"
#> [4] "x <- 1" "```"