Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

math_token_spacing

Specify spacing around math tokens


Description

Helper function to create the input for the argument math_token_spacing in tidyverse_style().

Usage

specify_math_token_spacing(zero = "'^'", one = c("'+'", "'-'", "'*'", "'/'"))

tidyverse_math_token_spacing()

Arguments

zero

Character vector of tokens that should be surrounded with zero spaces.

one

Character vector with tokens that should be surrounded by at least one space (depending on strict = TRUE in the styling functions style_text() and friends). See 'Examples'.

Functions

  • specify_math_token_spacing: Allows to fully specify the math token spacing.

  • tidyverse_math_token_spacing: Simple forwarder to specify_math_token_spacing with spacing around math tokens according to the tidyverse style guide.

Examples

style_text(
  "1+1   -3",
  math_token_spacing = specify_math_token_spacing(zero = "'+'"),
  strict = FALSE
)
style_text(
  "1+1   -3",
  math_token_spacing = specify_math_token_spacing(zero = "'+'"),
  strict = TRUE
)
style_text(
  "1+1   -3",
  math_token_spacing = tidyverse_math_token_spacing(),
  strict = FALSE
)
style_text(
  "1+1   -3",
  math_token_spacing = tidyverse_math_token_spacing(),
  strict = TRUE
)

styler

Non-Invasive Pretty Printing of R Code

v1.4.1
MIT + file LICENSE
Authors
Kirill Müller [aut], Lorenz Walthert [cre, aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.