RoundWhole | R Documentation |
Round values that are close two whole numbers
RoundWhole(x, digits = 9, onlyZeros = FALSE)
x |
vector or matrix |
digits |
parameter to |
onlyZeros |
Only round values close to zero |
When digits
is NA
, Inf
or NULL
, input is returned unmodified.
When there is more than one element in digits
or onlyZeros
,
rounding is performed column-wise.
Modified x
Øyvind Langsrud
x <- c(0.0002, 1.00003, 3.00014)
RoundWhole(x) # No values rounded
RoundWhole(x, 4) # One value rounded
RoundWhole(x, 3) # All values rounded
RoundWhole(x, NA) # No values rounded (always)
RoundWhole(x, 3, TRUE) # One value rounded
RoundWhole(cbind(x, x, x), digits = c(3, 4, NA))
RoundWhole(cbind(x, x), digits = 3, onlyZeros = c(FALSE, TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.