This function takes a vector and checks if any information is lost by rounding to a certain number of digits.

is.round(x, digits = 0)

Arguments

x

A vector.

digits

How many digits to round to.

Details

Returns TRUE if rounding to digits digits after the decimal can be done without losing information.

Examples

is.round(1:5)
#> [1] TRUE

x <- c(1, 1.2, 1.23)
is.round(x)
#> [1] FALSE
is.round(x,digits=2)
#> [1] TRUE