convert_u: Convert unit in equation

View source: R/units.R

convert_uR Documentation

Convert unit in equation

Description

In rare cases, it may be desirable to change the units of a variable within an equation. Use convert_u() to convert a variable to another matching unit. See u() for more information on the rules of specifying units. Note that units are only supported in Julia, not in R.

Usage

convert_u(x, unit_def)

Arguments

x

Variable

unit_def

Unit definition, e.g. u('seconds')

Value

Variable with new unit (only in Julia)

See Also

model_units(), unit_prefixes(), u(), drop_u()

Examples

# Change the unit of rate from minutes to hours
sfm <- xmile() |>
  build("rate", "constant", eqn = "10", units = "minutes") |>
  build("change", "flow",
    eqn = "(room_temperature - coffee_temperature) / convert_u(rate, u('hour'))"
  )


sdbuildR documentation built on Nov. 19, 2025, 5:07 p.m.