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

set_line_break_before_curly_opening

Set line break before a curly brace


Description

Rule:

  • Principle: Function arguments that consist of a braced expression always need to start on a new line

  • Exception: ... unless it's the last argument and all other arguments fit on the line of the function call

  • Exception: ... or they are named.

  • Extension: Also, expressions following on braced expressions also cause a line trigger.

Usage

set_line_break_before_curly_opening(pd)

Examples

## Not run: 
tryCatch(
  {
    f(8)
  },
  error = function(e) NULL
)
# last-argument case
testthat("braces braces are cool", {
  code(to = execute)
})
call2(
  x = 2,
  {
    code(to = execute)
  },
  c = { # this is the named case
    g(x = 7)
  }
)
tryGugus(
  {
    g5(k = na)
  },
  a + b # line break also here because
  # preceded by brace expression
)

## End(Not run)

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.