roundr.Rd
This function rounds the given value n to the nearest value created by r2.
roundr(n, r2 = c(4, 512, 4))
n | The number you want to round |
---|---|
r2 | Encodes the values plugged into the
|
A integer rounded to the nearest multiple of the third element in r2
roundr()
works by creating an array and finding which number n is closest to.
r2 contains all the input arguments for the seq()
function (being the min, max and step args) which are then parsed to seq()
to create an array of values.
roundr()
then takes the number to be round: n, and finds the minimum absolute difference between it and all values in the sequence created by r2.
Finally the number in the array closest to n is returned as the 'rounded' value.
Kyle Bario kylebario1@gmail.com