This function is intended for data frames / tibbles only and makes the units of columns that have numbers with units explicit in the column name. It also strips the units attribute from those columns using iso_strip_units
. The reverse function is iso_make_units_implicit
.
iso_make_units_explicit(df, prefix = " [", suffix = "]")
the data frame in which to make the units explicit
the prefix for the units
the suffix for the units
Other functions for values with units:
iso_get_units()
,
iso_is_double_with_units()
,
iso_make_units_implicit()
,
iso_strip_units()
,
iso_with_units()
# a data frame with implicit units
df <- tibble(peak = 1:5, height = iso_double_with_units(1:5, "V"))
df
#> # A tibble: 5 × 2
#> peak height
#> <int> <dbl[V]>
#> 1 1 1
#> 2 2 2
#> 3 3 3
#> 4 4 4
#> 5 5 5
# show with explicit units
iso_make_units_explicit(df)
#> # A tibble: 5 × 2
#> peak `height [V]`
#> <int> <dbl>
#> 1 1 1
#> 2 2 2
#> 3 3 3
#> 4 4 4
#> 5 5 5
# show with explicit units (custom prefix & suffix)
iso_make_units_explicit(df, prefix = ".", suffix = "")
#> # A tibble: 5 × 2
#> peak height.V
#> <int> <dbl>
#> 1 1 1
#> 2 2 2
#> 3 3 3
#> 4 4 4
#> 5 5 5