extractRcode: extractRcode pulls out the r-code blocks from Rmd files

View source: R/rutils.R

extractRcodeR Documentation

extractRcode pulls out the r-code blocks from Rmd files

Description

extractRcode pulls out the r-code blocks from Rmd or qmd files and saves them into a separate R file. This depends upon the prefix ⁠used to define R blocks at the top and bottom. So it 'knows' where they begin and where they end. Any R-code included that is not encased in the⁠ prefix will not be extracted.

Usage

extractRcode(indir, rmdfile, filename = "out.R")

Arguments

indir

the directory in which the rmd file is to be found and into which the output file will be placed.

rmdfile

name of Rmd/qmd file whose R code is to be extracted

filename

the name of the R file into which the r-code is to go.

Value

generates an R file in the indir but returns nothing

Examples

ddir <- getDBdir()
# syntax   extractRcode(pathtopath(ddir,"projects/AIRF/NWLML"),
#                       "Drivers_of_Productivity.qmd",
#                       filename="productivity.R")

haddonm/codeutils documentation built on April 5, 2025, 11:29 p.m.