Last chance! 50% off unlimited learning
Sale ends in
Round prices to the nearest specified increment
round_to_nearest(amount, to_nearest)
Price to be rounded
Increment to which price is to be rounded to
# Round to nearest 0.05 (5c)
library(dplyr)
prices <- c(4.45, 5.22, 0.16, 27.88, 112.19)
prices %>% round_to_nearest(0.05)
# Round to nearest $10
prices <- c(4.45, 5.22, 0.16, 27.88, 112.19)
prices %>% round_to_nearest(10)
Run the code above in your browser using DataLab