Internal function to check the dimensionality (i.e., units) of an object. First, check that the object is a units object. Second, try to convert the object to `desired_units` to ensure dimensionality is correct.

check_dimensionality(object, desired_units, variable_name = NULL)

Arguments

object

Object of which to check dimensionality

desired_units

Required dimensionality, given as units (e.g., "ft/s")

variable_name

Optional name of the object, for error reporting

Value

As of right now, nothing is returned

Details

Check dimensionality of object

Examples

if (FALSE) { # \dontrun{
object <- set_units(1, "ft")
desired_units <- "m"
check_dimensionality(object, "m") # passes

# error because object has wrong dimensionality
check_dimensionality(object, "m^2", "object")
check_dimensionality(object, "m^2") # error, note difference in error reporting

check_dimensionality(1, "m", "object") # error because object not a units object
} # }