Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potentially misleading characterisation of R for Data Science's pipes chapter. #27

Open
ReeceGoding opened this issue Jun 11, 2021 · 6 comments

Comments

@ReeceGoding
Copy link

ReeceGoding commented Jun 11, 2021

In the Pipes section, you claim "There are so many variations to learn that Hadley's R for Data Science book devotes a full chapter to pipes, 3415 words". This suggests that most of Hadley's time in that chapter is spent discussing the variations of the %>% pipe. I find this misleading. Opening that chapter, at least the online version, shows that most of it is spent discussing alternatives to pipes. Only one section is devoted to pipes other than the %>% pipe. By my count, this section is not even 300 words in length. To wit, the %>% pipe is originally described in chapter 5 and complexities like how a . can be piped to are not covered at all (the Tidyverse functions try their best to put the data argument first, so you rarely need .).

I know of no source that spends any great amount of words explaining the variations of the magrittr pipes. There are only four pipes in the entire library. Once you understand %>%, both %T>% and %<>% are trivial. Look no further than how short their documentation is. I'd argue that only %$% is complex, but it's easily understood after seeing a few examples.

@z3tt
Copy link

z3tt commented Sep 2, 2021

I don't want to open a new issue and it kinda fits here.

It would be great to see how the author now values the new, native base R pipe. If it's a bad idea to use pipes from a programing perspective, why did the R Core team decide to copy-paste the idea?

@BroVic
Copy link

BroVic commented Sep 3, 2021

@z3tt It's been a while since I read the article and frankly don't want to re-read it right now. However, I didn't come away with the impression that he was attacking the use of pipes per se...

@z3tt
Copy link

z3tt commented Sep 3, 2021

@BroVic I know Norm is not a fan of the pipe, I was just curious if this holds for the new base R pipe as well.

There is a statement that says that the pipe actually makes it harder to read code by adding "extra complexity" and that one can write unnested code anyway by running each step in isolation and assigning the output to an intermediate variable (https://github.com/matloff/TidyverseSkeptic). Frankly said, if this is an option for the author fine but I largely disagree that this makes it easier to read the code in comparison to a piped version of the same.

I do think it is about pipes per se because this statement also holds for the new |> pipe.

Anyway, just found a short note by Norm about the new pipe and, as it reads, R Core just added the "base pipe" as a friendly gesture for Rstudio (which I am highly sceptic of but well...):

The R Core Team offered an olive branch by including a "pipe" capability to base R. I've yet to see this gesture reciprocated by RStudio, but "hope springs eternal."

Source: https://github.com/matloff/R-vs.-Python-for-Data-Science

@BroVic
Copy link

BroVic commented Sep 3, 2021

@z3tt friendly gesture? I find that amusing. The native pipe was implemented as an improvement--ugly syntax aside. I also don't agree with that assessment 🙂

@BroVic
Copy link

BroVic commented Sep 7, 2021

@z3tt BTW I absolutely love your ggplot2 tutorial. Thank you!

@matloff
Copy link
Owner

matloff commented Mar 11, 2023

The native pipe was developed for base-R as an olive branch to RStudio., not because R Core thought it filled a need.

I don't use either kind of R pipes. I do use Unix shell pipes a lot; see my comments on another Issue posted for this package.

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

No branches or pull requests

4 participants