rounding | R Documentation |
Round a number to the nearest value.
integer_round(x, upper5 = TRUE)
decimal_floor(x, digits = 1)
decimal_ceiling(x, digits = 1)
integer_floor(x, base=10)
integer_ceiling(x, base=10)
x |
A numeric vector. |
upper5 |
Logical value that regulates the rounding in presence of the decimal .5. |
digits |
Integer indicating the number of decimal places to consider. |
base |
Integer value to use as step in rounding. The |
integer_round
rounds a decimal number to the nearest integer. When the decimal
is exactly .5, the number is rounded to the upper integer (upper5 = T
).
The opposite behavior is obtained when upper5 = F
.
decimal_floor
and decimal_ceiling
round a decimal number to the nearest
decimal digit, specified by digits
.
integer_floor
and integer_ceiling
round a number to the nearest integer
value specified by base
.
round
x <- c(8.87, 9.26, 10.5, 11.5, 12.5)
integer_round(x)
integer_round(x, upper5=FALSE)
round(x) # round has a different behavior for 10.5 and 11.5
decimal_floor(x)
decimal_ceiling(x)
x <- c(1, 9, 24, 32, 59)
integer_floor(x)
integer_ceiling(x)
integer_ceiling(x, base=5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.