round in r code example
Example 1: how to get the round in r
floor(x) # rounds to the smallest nearest integer
ceiling(x) # rounds to the largest nearest integer
trunc(x) rounds to the nearest integer in the direction of 0
format(round(x, 2), nsmall = 2)
Example 2: R round float values
> round(123.456,digits=2)
[1] 123.46
Example 3: R round values up
# Round up to the next integer
ceiling(x)