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.
max
Specif
How about:
roundUp <- function(x,to=10) { to*(x%/%to + as.logical(x%%to)) }
Which gives:
> roundUp(c(4,6.1,30.1,100.1)) [1] 10 10 40 110 > roundUp(4,5) [1] 5 > roundUp(12,7) [1] 14