Round numeric data to specified digits
stm_round.Rd
stm_round()
rounds numeric data to a specified number of digits.
If the input is a list, the rounding is applied element-wise to each
numeric element.
Details
The function applies rounding to numeric data. If dat
is a list,
it will apply rounding element-wise to each numeric element in the list.
If an error occurs during rounding, the original data is returned.
Examples
stm_round(3.14159, digits = 2)
#> [1] 3.14
stm_round(3.14159, digits = "two")
#> [1] 3.14159
a <- list(3.14159, "hello", 2.71828, list(1.61803, "world"))
stm_round(a, digits = 3)
#> [[1]]
#> [1] 3.142
#>
#> [[2]]
#> [1] "hello"
#>
#> [[3]]
#> [1] 2.718
#>
#> [[4]]
#> [[4]][[1]]
#> [1] 1.61803
#>
#> [[4]][[2]]
#> [1] "world"
#>
#>