Guess dbh units based on minimum and maximum values of dbh.

guess_dbh_unit(x)

Arguments

x

A numeric vector.

Value

A length-1 character string.

Examples

# Case when # min(x, na.rm = TRUE) < 1.1 && # max(x, na.rm = TRUE) < 500 guess_dbh_unit(c(1.0, 100))
#> [1] "cm" #> attr(,"class") #> [1] "guessed" "character"
# min is too large try(guess_dbh_unit(c(1.2, 499)))
#> Error : Can't guess dbh units.
# max is too large try(guess_dbh_unit(c(1.0, 501)))
#> Error : Can't guess dbh units.
# min is too large and max is too large try(guess_dbh_unit(c(1.2, 501)))
#> Error : Can't guess dbh units.
# Case when # min(x, na.rm = TRUE) > 9 && # max(x, na.rm = TRUE) > 500 guess_dbh_unit(c(9.1, 500.1))
#> [1] "mm" #> attr(,"class") #> [1] "guessed" "character"
# min is too small try(guess_dbh_unit(c(8.9, 500.1)))
#> Error : Can't guess dbh units.
# max is too small try(guess_dbh_unit(c(9.1, 500)))
#> Error : Can't guess dbh units.
# min is too small and max is too small try(guess_dbh_unit(c(8.9, 500)))
#> Error : Can't guess dbh units.