Skip to content

No line break after pipe inserted #470

Description

@msberends

I was quite surprised to learn that

styler::style_text("my_df %>% group_by(var1, var2, var3) %>% summarise(a = mean(value), b = median(value), c = sum(value)) %>% filter(a > 2, b < 1)")

leads to

my_df %>% group_by(var1, var2, var3) %>% summarise(a = mean(value), b = median(value), c = sum(value)) %>% filter(a > 2, b < 1)

and not something like

my_df %>%
  group_by(var1, var2, var3) %>%
  summarise(a = mean(value), b = median(value)) %>%
  filter(a > 2, b < 1)

So pipes are not followed by a line break. I looked at http://styler.r-lib.org/articles/introducing_styler.html and https://lorenzwalthert.netlify.com/post/customizing-styler-the-quick-way/ how the tidyverse default style is being applied, and I don't see anything resembling the proposed style on https://style.tidyverse.org/pipes.html#whitespace:

# Good
iris %>%
  group_by(Species) %>%
  summarize_if(is.numeric, mean) %>%
  ungroup() %>%
  gather(measure, value, -Species) %>%
  arrange(value)

# Bad
iris %>% group_by(Species) %>% summarize_all(mean) %>%
ungroup %>% gather(measure, value, -Species) %>%
arrange(value)

Isn't or shouldn't this be the default behaviour of styler::tidyverse_style()?? Can I change this behaviour?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions