3 ms·
All %fun% constructs are just simple functions that can be created by the user and can be used as infix operators. Base R has a few of those: %in%, %o%, %*%, %x
by kkoncevicius 6y ago
All %fun% constructs are just simple functions that can be created by the user and can be used as infix operators. Base R has a few of those: %in%, %o%, %*%, %x%, %%, %/%.
magrittr created %>% which, when used in infix: x %>% f() calls the function on the right side with the argument on the left side f(x).
There are package that provide tons more. For example: https://github.com/moodymudskipper/inops https://github.com/moodymudskipper/inops . And you can easily create your own:
`%sum%` <- function(x, y) x + y
1 %sum% 2
[1] 3