Sets nicer options. All arguments are passed to the options function. This function also sets ipck = TRUE in rc.settings.

set_startup_options(
  digits = 4L,
  show.signif.stars = FALSE,
  useFancyQuotes = FALSE,
  width = cli::console_width(),
  Ncpus = max(1L, parallel::detectCores() - 1L),
  continue = " ",
  max.print = 100L,
  servr.daemon = TRUE,
  max = 10L,
  mc.cores = max(1L, parallel::detectCores() - 1L),
  warnPartialMatchArgs = TRUE,
  warnPartialMatchDollar = TRUE,
  warnPartialMatchAttr = TRUE,
  scipen = 999L,
  HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(),
    R.version$platform, R.version$arch, R.version$os)),
  download.file.extra = sprintf("--header \"User-Agent: R (%s)\"",
    paste(getRversion(), R.version$platform, R.version$arch, R.version$os)),
  setWidthOnResize = TRUE,
  show.error.locations = TRUE,
  check.bounds = FALSE,
  menu.graphics = FALSE,
  error = "rlang",
  ...
)

Arguments

digits

Default 4

show.signif.stars

Default FALSE

useFancyQuotes

Default FALSE

width

Default cli::console_width() + 13L. See details.

Ncpus

Default number of CPUs - 1. Used for parallel pkg installs.

continue

Default blank space (remove the default +)

max.print

Default 100 to avoid blow up

servr.daemon

Default TRUE. For xaringan presentations

max

Default 10. For List printing

mc.cores

Default number of CPUs - 1. Used for parallel computing

warnPartialMatchArgs, warnPartialMatchAttr, warnPartialMatchDollar

Default TRUE. Warn if using partial arguments.

scipen

Default 999. Always print out full numbers, i.e. not 1e2

HTTPUserAgent

Used by RStudio Package Manager (RSPM).

download.file.extra

Used by RSPM for curl/wget installs, e.g. Rscript.

setWidthOnResize

If set and TRUE, R run in a terminal using a recent readline library will set the width option when the terminal is resized.

show.error.locations

Show error locations for sourcing

check.bounds

logical, defaulting to FALSE. If true, a warning is produced whenever a vector (atomic or list) is extended, by something like x <- 1:3; x[5] <- 6.

menu.graphics

Default FALSE. Logical: should graphical menus be used if available?

error

Default rlang. If rlang is installed, then error = rlang::entrace.

...

Other arguments passed to options.

Details

The width is only used in an R terminal (not RStudio). However, fancy prompts that involve colours (such as grey), mean that the column count is off as grey is grey()(cli::symbol$pointer) is translated to a 17 character Unicode string. My slightly hacky solution is to add a line break in the prompt, than add an additional 17 characters to the width to pad out the width.