run_and_format: Run a code snippet and copy formatted code and output to...

run_and_formatR Documentation

Run a code snippet and copy formatted code and output to clipboard

Description

This builds on the reprex::reprex() function to take a chunk of code, run it and copy the formatted code and output to the clipboard. Note that this does NOT run in a clean session and is thus unlikely to create reproducible examples. Instead, it is intended to be used to quickly get a formatted bit of code and output that is not self-contained, e.g., for teaching materials.

Usage

run_and_format(code = NULL)

Arguments

code

The code to run - can be NULL, then the code is retrieved from the clipboard.

Examples

if (interactive()) {
  name <- "Lukas"
  run_and_format(paste("My name is", name))
}

LukasWallrich/timesaveR documentation built on Nov. 29, 2024, 4:47 a.m.