I've recently seen code like this:
library(dplyr)
mtcars %.% mutate(carb_10 = carb %/% 10)
And this....
mtcars %.% mutate(carb_10 = carb %% 10)
Can anyone explain what %/% and %% do in above code?
From the ?"%%"
help page
%%
indicates x mod y and%/%
indicates integer division. It is guaranteed thatx == (x %% y) + y * ( x %/% y )
(up to rounding error) unless y == 0 where the result of%%
is NA_integer_ or NaN (depending on the typeof of the arguments).