This function calculates the range (minimum and maximum values) of a given numeric vector. It then formats and rounds these values to a specified number of decimal places, returning them as a string.

zrange(x, digits = 2)

Arguments

x

A numeric vector for which the range (min and max) is to be calculated.

digits

An integer indicating the number of decimal places to which the results will be rounded. Defaults to 2.

Value

A character string representing the range of x, formatted as '(min, max)', where 'min' and 'max' are the minimum and maximum values of x rounded to digits decimal places.

Examples

zrange(c(1.234, 5.678, 9.012))
#> [1] "(1.23, 9.01)"
zrange(c(10, 20, 30, 40, 50), digits = 1)
#> [1] "(10.0, 50.0)"