Skip to content

Support pipes on one line? - #28

Merged
hadley merged 1 commit into
tidyverse:masterfrom
krlmlr:patch-1
Jul 26, 2017
Merged

hadley merged 1 commit into
tidyverse:masterfrom
krlmlr:patch-1

Conversation

@krlmlr

@krlmlr krlmlr commented Jul 14, 2017

Copy link
Copy Markdown
Member

This is necessary in particular for pipes used as an argument to a function call, e.g. in a join:

lhs %>%
  select(a, b) %>%
  left_join(rhs %>% select(a, c), by = "a")

@hadley: Can you please take a look?

@hadley

hadley commented Jul 14, 2017

Copy link
Copy Markdown
Member

Rather than tweaking the existing advice, I'd rather add a new section. Something like:

There's one exception to this rule: sometimes it's useful to include a short pipe as an argument to a function in a longer pipe. Carefully consider whether the code is more readable with a short inline pipe (which doesn't a require lookup elsewhere) or if it's better to move the code outside the pipe and give it an evocative name.

Then you can use the left-join example explicitly.

@krlmlr

krlmlr commented Jul 25, 2017

Copy link
Copy Markdown
Member Author

I've rearranged a bit, and also added a positive explanation for assignments.

@hadley
hadley merged commit 356cc51 into tidyverse:master Jul 26, 2017
@hadley

hadley commented Jul 26, 2017

Copy link
Copy Markdown
Member

Thanks!

@krlmlr
krlmlr deleted the patch-1 branch September 16, 2017 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants