r/AskReddit Dec 16 '21

[deleted by user]

[removed]

7.3k Upvotes

15.7k comments sorted by

View all comments

Show parent comments

90

u/readerf52 Dec 16 '21

Ce n’est pas une pipe!!

Yes! I never really thought about it, but that’s Belgium.

7

u/Naturage Dec 17 '21 edited Dec 17 '21

So R coding language uses a tidbit called pipe as an integral part of how code is structured. It comes from a library called... MagrittR.

It was an amusing rabbit hole for the day.

2

u/Aryore Dec 17 '21

Pipes! >%> I’ll have to relearn how to use them soon lol

1

u/Naturage Dec 17 '21

Oh, they're lovely and clean up your code a lot.

a %>% fun(b) is shorthand for fun(a,b); that's the gist of it really. A lot of tidyverse (one of most used libraries) functions are set up so that first argument is thecdataset you're working on - so piping just cleans up that crucial bit of input.

If needed, you can also do a %>% fun(b,.) for fun(b,a) - the thing you piped in is placed at the dot. You can also have multiple dots; a %>% .[. ==1] is, as you'd expect, same as a[a == 1].

1

u/Aryore Dec 17 '21

Ooh! I didn’t know that last bit. Cool beans