datacarpentry / R-ecology-lesson

Data Analysis and Visualization in R for Ecologists
https://datacarpentry.org/R-ecology-lesson/
Other
314 stars 508 forks source link

How recent are "pipes" as a feature in R? #764

Closed maneesha closed 4 months ago

maneesha commented 3 years ago

In the Manipulating data episode it says pipes are a recent addition to R. It seems like pipes have been around since 2014. See this and this.

Teebusch commented 3 years ago

Hi @maneesha , thank you for this comment. I agree that pipes have been around for long enough to not be "recent" anymore (although in my personal experience, some people who learned R long ago haven't gotten familiar with the tidyverse yet).

I think the intention of writing this may have been to point out that the pipe is not part of base R. Perhaps we can change it to something like that. How about writing something like "The pipe is a special operator that is part of the tidyverse"?

Lucy-Quirk commented 3 years ago

I agree with @maneesha the intention was likely to let the learners know that pipes are not base R, although it is no longer recent. I would like to point out that pipes are also available through the dplyr package. I would suggest something like: "Pipes are a special operator that improves the readability of your code by condensing many commands into a few lines of functions. "

kiblerchris commented 2 years ago

It's worth noting that R version 4.1 introduced a new version of the pipe operator that is included in the base installation. It is conceptually similar to the pipe operator from {tidyverse}, but the syntax is a bit different. So now there are now two different versions of the pipe operator. This blog post compares the two versions.

I think that @maneesha is correct when she says that the {tidyverse} pipe operator is not a recent addition. In my experience, it is now ubiquitous in many coding communities. But the base pipe operator is a recent addition.

I don't think the lesson should utilize the base pipe operator until it gains some traction. But it is probably worth mentioning it in passing when the lesson is revised.

mantoniou commented 2 years ago

Originally, a pipe operator was introduced in 2014 in magrittr package, implemented as %>%, with which you may pipe a value forward into an expression or function call. It is used extensively with all tidyverse packages (dplyr, tidyr etc.). But since May 2021, under R version 4.1.0, a native R pipe operator has been introduced. It is implemented as |>, with similar behaviour to the original magrittr pipe operator. I think it is worth mentioning that the idea of the pipe, as far as I am aware, probably comes from UNIX/LINUX, where it is implemented as |

ooyerind commented 1 year ago

I did not have any clue about the new pipe (|>) until a couple of months ago. The new pipe is handy because it is very easy for my students to remember, as opposed to the older pipe (%>%) which is difficult for my students to remember.

bisesi commented 1 year ago

I agree it seems worth mentioning the base R pipe into the lesson as an alternative, while noting that there are a few differences between it and the magrittr pipe operator. For example, while the magrittr pipe can accept piped function calls without parentheses, the native pipe can't. Placeholding also works differently between the two. A lot of the details are unnecessary for this particular point in the lesson, but maybe linking a cheatsheet would allow people to identify which pipe might work best for them.

tobyhodges commented 4 months ago

Thanks everyone for contributing to this discussion. The lesson underwent a major update and reorganisation when https://github.com/datacarpentry/R-ecology-lesson/pull/887 was merged. As this issue relates to content in a version of the lesson before that update took place, I will close it. Please open a new issue if you believe that some or all of the changes being discussed here remain relevant to the redesigned lesson, linking to this thread where appropriate.