I would like to create a new style using the styler package that is equivalent to the Tidyverse style, with two exceptions: 1) There should always be a line break after the opening of a function call, and 2) there should always be a line break before the closing of a function call.
library(tidyverse)
# original
diamonds |>
mutate(new = log(carat), sum = x + z, my_new_column = log(x)) |>
filter(new < 3)
# desired format after formatting
diamonds |>
mutate(
new = log(carat),
sum = x + z,
my_new_column = log(x)
) |>
filter(new < 3)
# Tidyverse style after formatting
diamonds |>
mutate(new = log(carat),
sum = x + z,
my_new_column = log(x)) |>
filter(new < 3)
It can’t be that hard to achieve but after reading the docs I still couldn’t get it to work. I have already put together something hacky using both the styler and rstudioapi packages but would prefer a proper style definition.