knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(erikmisc)

Read an Rmd file, update existing prefixed code chunks, and renumber. (These are replaced with a .txt extension to not interfere with other vignettes.)

e_rmd_name_chunks(
    fn_in             = "test_in_Rmd.txt"
  , fn_out            = "test_out_Rmd.txt"
  , prefix_chunk_name = "chunk-"
  )

Review the input and output files to see how the chunk header names have been updated.

test_in.Rmd
 8 : ```r
22 : ```{R cars}
28 : ```r
32 : ```{  R  }
36 : ```r
40 : ```{   R, eval=FALSE}
44 : ```r
48 : ```r
52 : ```r
56 : ```{R chunk-XXX2 , eval=FALSE}
60 : ```{R chunk-XXX3 , eval=FALSE}
64 : ```r
68 : ```r
72 : ```r
81 : ```r

# These code chunk headers were changed to those below:

test_out.Rmd
 8 : ```r
22 : ```r
28 : ```r
32 : ```r
36 : ```r
40 : ```r
44 : ```r
48 : ```r
52 : ```r
56 : ```r
60 : ```r
64 : ```r
68 : ```r
72 : ```r
81 : ```r


erikerhardt/erikmisc documentation built on April 17, 2025, 10:48 a.m.