style
style copied to clipboard
Bad examples for short-pipes?
The section on short pipes doesn't have any "bad" examples:
https://style.tidyverse.org/pipes.html#short-pipes
# Good
iris %>% arrange(Species)
iris %>%
arrange(Species)
arrange(iris, Species)
Is that intentional? According to the text, it looks like maybe the first two of those should be marked as "bad", but I'm not sure
Nevermind, I think I may have been mis-reading this section. It's saying "You don't have to split a one-call pipe into two lines if it fits in one line, but in that case, consider writing it as a simple function call".
Does that, by extension, speak to the converse?
Namely, if a call does require >1 line (e.g. a dplyr::select()
with 10+ columns), it should always be as a pipe?
# BAD
dplyr::select(
DF,
col1, col2, col3, ...
)
vs.
# GOOD
DF %>% dplyr::select(
col1, col2, col3, ...
)