%.% vs. %>%

257 views
Skip to first unread message

Gabor Grothendieck

unread,
Feb 25, 2014, 4:41:34 PM2/25/14
to manip...@googlegroups.com
What is the motivation for a magittr package with %>% and dplyr with %.% rather than just doing everything with %>% or %.% ?

> library(dplyr)
> iris %.% "["(-5) %.% colSums()
Sepal.Length  Sepal.Width Petal.Length  Petal.Width 
       876.5        458.6        563.7        179.9 

> library(magrittr)
> iris %>% "["(-5) %>% colSums()
Sepal.Length  Sepal.Width Petal.Length  Petal.Width 
       876.5        458.6        563.7        179.9 

Hadley Wickham

unread,
Feb 25, 2014, 4:59:30 PM2/25/14
to Gabor Grothendieck, manipulatr
dplyr will move to use magrittr in the next version. It will continue
to support %.%, but I'll switch all examples to use %>% and eventually
deprecate %.%.

I prefer %>% to %.% because:

* it's easier to type
* it's not symmetric

I prefer the functionality provided by magrittr because it lets put
the LHS in any argument (and it's well tested).

Hadley
> --
> You received this message because you are subscribed to the Google Groups
> "manipulatr" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to manipulatr+...@googlegroups.com.
> To post to this group, send email to manip...@googlegroups.com.
> Visit this group at http://groups.google.com/group/manipulatr.
> For more options, visit https://groups.google.com/groups/opt_out.



--
http://had.co.nz/

Tim Bates

unread,
Feb 26, 2014, 1:01:42 AM2/26/14
to plyr
erk. %>% looks like %in% to me: a comparator, not a pipe.

“.”  at least has the history of being a concatenator in languages like PHP…

But why not %->% (generalising R’s use of "sets” to “goes to”) 

Even  %|% is not a lot better, as for most people that will read “some kind of logical OR" not “unix pipe”

best, tim

Antonio Piccolboni

unread,
Apr 1, 2014, 10:59:12 PM4/1/14
to manip...@googlegroups.com
It's %|% in plyrmr. Unix rules.


Antonio

Timothy Bates

unread,
Apr 2, 2014, 8:28:36 AM4/2/14
to manip...@googlegroups.com
%.% and  %|% make sense to me. magittr seems the odd one out (the math comparator symbol leaps out in a way that  "pipe" and . don't  to me)

tim
Reply all
Reply to author
Forward
0 new messages