reprex_render {reprex}R Documentation

Render a document in a new R session

Description

This is a wrapper around rmarkdown::render() that enforces the "reprex" mentality. Here's a simplified version of what happens:

callr::r(
  function(input) {
    rmarkdown::render(input, envir = globalenv(), encoding = "UTF-8")
  },
  args = list(input = input),
  spinner = is_interactive(),
  stdout = std_file, stderr = std_file
)

Key features to note

reprex_render() is designed to work with the reprex_document() output format, typically through a call to reprex(). reprex_render() may work with other R Markdown output formats, but it is not well-tested.

Usage

reprex_render(input, html_preview = NULL, encoding = "UTF-8")

Arguments

input

The input file to be rendered. This can be a .R script or a .Rmd R Markdown document.

html_preview

Logical. Whether to show rendered output in a viewer (RStudio or browser). Always FALSE in a noninteractive session. Read more about opt().

encoding

The encoding of the input file. Note that the only acceptable value is "UTF-8", which is required by knitr as of v1.24. This is exposed as an argument purely for technical convenience, relating to the "Knit" button in the RStudio IDE.

Value

The output of rmarkdown::render() is passed through, i.e. the path of the output file.

Examples

## Not run: 
reprex_render("input.Rmd")

## End(Not run)

[Package reprex version 2.1.0 Index]