This function is intended for data frames / tibbles only and makes the specified columns explicit with the target units in the column name.
make_qty_units_explicit(df, ..., prefix = " [", suffix = "]")
the data frame in which to make the units explicit
named arguments for the columns that should be made explicit and their units, e.g. salt_weight = "mg", salt_concentration = "M"
.
the prefix for the units
the suffix for the units
Other quantity functions:
check_quantities
,
metric_scaling
,
quantities
,
quantity_data
,
quantity_units
# data frame with quantities
df <- tibble(x = qty(1:5, "mg"), y = qty(1:5, "L"))
df
#> # A tibble: 5 × 2
#> x y
#> <mk_mass> <mk_volum>
#> 1 1 1
#> 2 2 2
#> 3 3 3
#> 4 4 4
#> 5 5 5
# show with explicit units
make_qty_units_explicit(df, x = "mg")
#> # A tibble: 5 × 2
#> `x [mg]` y
#> <dbl> <mk_volum>
#> 1 1 1
#> 2 2 2
#> 3 3 3
#> 4 4 4
#> 5 5 5
make_qty_units_explicit(df, x = "g", y = "mL")
#> # A tibble: 5 × 2
#> `x [g]` `y [mL]`
#> <dbl> <dbl>
#> 1 0.001 1000
#> 2 0.002 2000
#> 3 0.003 3000
#> 4 0.004 4000
#> 5 0.005 5000