If we call knitr::purl("purl.Rmd"), it generates the following R script (with the filename by default):

    If you want to retain all the text, you may use the argument , which generates the R script below:

    Inline R expressions are ignored by default. If you want to include them in the R script, you need to set the global R option options(knitr.purl.inline = TRUE) before calling .