reprex_options {reprex}R Documentation

reprex options

Description

Some reprex() behaviour can be controlled via an option, providing a way for the user to set personal defaults. The pattern for such option names is ⁠reprex.<arg>⁠, where ⁠<arg>⁠ is an argument of reprex(). Here are the main ones:

A few more options exist, but are only relevant to specific situations:

Here's code you could put in .Rprofile to set reprex options. It would be rare to want non-default behaviour for all of these! We only do so here for the sake of exposition:

options(
  reprex.advertise       = FALSE,
  reprex.session_info    = TRUE,
  reprex.style           = TRUE,
  reprex.html_preview    = FALSE,
  reprex.comment         = "#;-)",
  reprex.tidyverse_quiet = FALSE,
  reprex.std_out_err     = TRUE,
  reprex.venue           = "html", # NOTE: only affects reprex_selection()!
  reprex.highlight.hl_style  = "acid", # NOTE: only affects RTF venue
  reprex.highlight.font      = "Andale Mono Regular",
  reprex.highlight.font_size = 35,
  reprex.highlight.other     = "--line-numbers"
)

The function usethis::edit_r_profile() is handy for creating and/or opening your .Rprofile.

Explaining the opt() helper

Arguments that appear like so in reprex():

reprex(..., arg = opt(DEFAULT), ...)

get their value according to this logic:

user-specified value or, if not given,
  getOption("reprex.arg") or, if does not exist,
    DEFAULT

It's shorthand for:

f(..., arg = getOption("reprex.arg", DEFAULT), ...)

This is not an exported function and should not be called directly.


[Package reprex version 2.1.1 Index]