Skip to contents

Add or modify a units column

Usage

set_units(x, units)

Arguments

x

A data frame or a harp_list.

units

The units name to put in the units column.

Value

A data frame or harp_list of the same size as x with the units column either added or modified.

Examples

# det_point_df has no units column
det_point_df
#> ::deterministic point forecast:: # A tibble: 48 × 6
#>    fcst_model fcst_dttm           lead_time valid_dttm            SID  fcst
#>  * <chr>      <dttm>                  <dbl> <dttm>              <dbl> <dbl>
#>  1 point      2021-01-01 00:00:00         0 2021-01-01 00:00:00  1001 0.300
#>  2 point      2021-01-01 00:00:00         1 2021-01-01 01:00:00  1001 0.611
#>  3 point      2021-01-01 00:00:00         2 2021-01-01 02:00:00  1001 0.802
#>  4 point      2021-01-01 00:00:00         3 2021-01-01 03:00:00  1001 0.361
#>  5 point      2021-01-01 00:00:00         4 2021-01-01 04:00:00  1001 0.213
#>  6 point      2021-01-01 00:00:00         5 2021-01-01 05:00:00  1001 0.736
#>  7 point      2021-01-01 00:00:00         6 2021-01-01 06:00:00  1001 0.177
#>  8 point      2021-01-01 00:00:00         7 2021-01-01 07:00:00  1001 0.866
#>  9 point      2021-01-01 00:00:00         8 2021-01-01 08:00:00  1001 0.109
#> 10 point      2021-01-01 00:00:00         9 2021-01-01 09:00:00  1001 0.436
#> # ℹ 38 more rows

# Set units to "degC"
new_det_point_df <- set_units(det_point_df, "degC")
new_det_point_df
#> ::deterministic point forecast:: # A tibble: 48 × 7
#>    fcst_model fcst_dttm           lead_time valid_dttm            SID  fcst
#>    <chr>      <dttm>                  <dbl> <dttm>              <dbl> <dbl>
#>  1 point      2021-01-01 00:00:00         0 2021-01-01 00:00:00  1001 0.300
#>  2 point      2021-01-01 00:00:00         1 2021-01-01 01:00:00  1001 0.611
#>  3 point      2021-01-01 00:00:00         2 2021-01-01 02:00:00  1001 0.802
#>  4 point      2021-01-01 00:00:00         3 2021-01-01 03:00:00  1001 0.361
#>  5 point      2021-01-01 00:00:00         4 2021-01-01 04:00:00  1001 0.213
#>  6 point      2021-01-01 00:00:00         5 2021-01-01 05:00:00  1001 0.736
#>  7 point      2021-01-01 00:00:00         6 2021-01-01 06:00:00  1001 0.177
#>  8 point      2021-01-01 00:00:00         7 2021-01-01 07:00:00  1001 0.866
#>  9 point      2021-01-01 00:00:00         8 2021-01-01 08:00:00  1001 0.109
#> 10 point      2021-01-01 00:00:00         9 2021-01-01 09:00:00  1001 0.436
#> # ℹ 38 more rows
#> # ℹ 1 more variable: units <chr>

# Modify the units name to "degrees_C"
set_units(new_det_point_df, "degrees_C")
#> ::deterministic point forecast:: # A tibble: 48 × 7
#>    fcst_model fcst_dttm           lead_time valid_dttm            SID  fcst
#>    <chr>      <dttm>                  <dbl> <dttm>              <dbl> <dbl>
#>  1 point      2021-01-01 00:00:00         0 2021-01-01 00:00:00  1001 0.300
#>  2 point      2021-01-01 00:00:00         1 2021-01-01 01:00:00  1001 0.611
#>  3 point      2021-01-01 00:00:00         2 2021-01-01 02:00:00  1001 0.802
#>  4 point      2021-01-01 00:00:00         3 2021-01-01 03:00:00  1001 0.361
#>  5 point      2021-01-01 00:00:00         4 2021-01-01 04:00:00  1001 0.213
#>  6 point      2021-01-01 00:00:00         5 2021-01-01 05:00:00  1001 0.736
#>  7 point      2021-01-01 00:00:00         6 2021-01-01 06:00:00  1001 0.177
#>  8 point      2021-01-01 00:00:00         7 2021-01-01 07:00:00  1001 0.866
#>  9 point      2021-01-01 00:00:00         8 2021-01-01 08:00:00  1001 0.109
#> 10 point      2021-01-01 00:00:00         9 2021-01-01 09:00:00  1001 0.436
#> # ℹ 38 more rows
#> # ℹ 1 more variable: units <chr>