Skip to content

Instantly share code, notes, and snippets.

@hrbrmstr
Created March 6, 2016 16:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrbrmstr/80393a8c88c84b84f3ba to your computer and use it in GitHub Desktop.
Save hrbrmstr/80393a8c88c84b84f3ba to your computer and use it in GitHub Desktop.
hack-ish way to get all the code examples from your package
fil <- list.files("man", full.names=TRUE)
cat(sapply(fil, function(x) {
rd <- tools::parse_Rd(x)
ex <- rd[devtools:::rd_tags(rd) == "examples"]
trimws(paste0(devtools:::process_ex(ex, run=FALSE), sep="", collapse="\n"))
}, USE.NAMES=FALSE))
@mrhili
Copy link

mrhili commented Sep 13, 2023

In summary, this script is designed to extract code examples from R documentation files and print them to the console, making it easier to view and work with the example code provided in the documentation. It appears to be a utility for developers working with R packages or functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment