I am writing a function to plot data. I would like to specify a nice round number for the y-axis max that is greater than the max of the dataset.
Specif
I tried this without using any external library or cryptic features and it works!
Hope it helps someone.
ceil <- function(val, multiple){
div = val/multiple
int_div = as.integer(div)
return (int_div * multiple + ceiling(div - int_div) * multiple)
}
> ceil(2.1, 2.2)
[1] 2.2
> ceil(3, 2.2)
[1] 4.4
> ceil(5, 10)
[1] 10
> ceil(0, 10)
[1] 0