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?
In R:
In Python, you can do it by simply using: %
In R:
In Python, you can do it by simply using: //
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With