Wondering if there an exists a function that can round a number up or down as I noticed that
as.integer(5.99999)
gives me 5, so it looks like as.integer coerces a numeric to an integer by dropping any number after the decimal place. Thank you!
The round()
function works great. You can do the following to get a result of 6:
as.integer(round(5.99999))
If you want it to round up or down, use the ceiling()
or floor()
functions, respectively, in place of the round()
function. Ex:
as.integer(ceiling(5.9999))
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