select_members
is used to select specific ensemble members from a
data frame along with all other columns. The method can also be applied to
a harp_list
of ensemble data frames.
Arguments
- .data
A data frame with ensemble members or a
harp_list
- members
The members to select. Can be a numeric vector, or a named list to select members from specific forecast models in a
harp_list
object.- include_lagged
Logical. Whether to include lagged ensemble members in the selection.
- invert
Logical. If
TRUE
all members except those provided inmembers
are returned.
Value
A data frame with the selected members or a harp_list
of
data frames with the selected ensemble members.
Examples
select_members(ens_point_df, 0)
#> ::ensemble point forecast:: # A tibble: 48 × 5
#> fcst_dttm lead_time valid_dttm SID point_mbr000
#> <dttm> <dbl> <dttm> <dbl> <dbl>
#> 1 2021-01-01 00:00:00 0 2021-01-01 00:00:00 1001 0.277
#> 2 2021-01-01 00:00:00 1 2021-01-01 01:00:00 1001 0.650
#> 3 2021-01-01 00:00:00 2 2021-01-01 02:00:00 1001 0.601
#> 4 2021-01-01 00:00:00 3 2021-01-01 03:00:00 1001 0.427
#> 5 2021-01-01 00:00:00 4 2021-01-01 04:00:00 1001 0.0798
#> 6 2021-01-01 00:00:00 5 2021-01-01 05:00:00 1001 0.762
#> 7 2021-01-01 00:00:00 6 2021-01-01 06:00:00 1001 0.347
#> 8 2021-01-01 00:00:00 7 2021-01-01 07:00:00 1001 0.488
#> 9 2021-01-01 00:00:00 8 2021-01-01 08:00:00 1001 0.438
#> 10 2021-01-01 00:00:00 9 2021-01-01 09:00:00 1001 0.662
#> # ℹ 38 more rows
select_members(ens_grid_df, 1)
#> ::ensemble gridded forecast:: # A tibble: 24 × 4
#> fcst_dttm lead_time valid_dttm grid_mbr001
#> <dttm> <dbl> <dttm> <geolist>
#> 1 2021-01-01 00:00:00 0 2021-01-01 00:00:00 [5 × 5]
#> 2 2021-01-01 00:00:00 1 2021-01-01 01:00:00 [5 × 5]
#> 3 2021-01-01 00:00:00 2 2021-01-01 02:00:00 [5 × 5]
#> 4 2021-01-01 00:00:00 3 2021-01-01 03:00:00 [5 × 5]
#> 5 2021-01-01 00:00:00 4 2021-01-01 04:00:00 [5 × 5]
#> 6 2021-01-01 00:00:00 5 2021-01-01 05:00:00 [5 × 5]
#> 7 2021-01-01 00:00:00 6 2021-01-01 06:00:00 [5 × 5]
#> 8 2021-01-01 00:00:00 7 2021-01-01 07:00:00 [5 × 5]
#> 9 2021-01-01 00:00:00 8 2021-01-01 08:00:00 [5 × 5]
#> 10 2021-01-01 00:00:00 9 2021-01-01 09:00:00 [5 × 5]
#> # ℹ 14 more rows
# More than one member can be selected
select_members(ens_point_df, c(0, 1))
#> ::ensemble point forecast:: # A tibble: 48 × 6
#> fcst_dttm lead_time valid_dttm SID point_mbr000
#> <dttm> <dbl> <dttm> <dbl> <dbl>
#> 1 2021-01-01 00:00:00 0 2021-01-01 00:00:00 1001 0.277
#> 2 2021-01-01 00:00:00 1 2021-01-01 01:00:00 1001 0.650
#> 3 2021-01-01 00:00:00 2 2021-01-01 02:00:00 1001 0.601
#> 4 2021-01-01 00:00:00 3 2021-01-01 03:00:00 1001 0.427
#> 5 2021-01-01 00:00:00 4 2021-01-01 04:00:00 1001 0.0798
#> 6 2021-01-01 00:00:00 5 2021-01-01 05:00:00 1001 0.762
#> 7 2021-01-01 00:00:00 6 2021-01-01 06:00:00 1001 0.347
#> 8 2021-01-01 00:00:00 7 2021-01-01 07:00:00 1001 0.488
#> 9 2021-01-01 00:00:00 8 2021-01-01 08:00:00 1001 0.438
#> 10 2021-01-01 00:00:00 9 2021-01-01 09:00:00 1001 0.662
#> # ℹ 38 more rows
#> # ℹ 1 more variable: point_mbr001 <dbl>
# Select member 0 from a harp_list
select_members(ens_point_list, 0)
#> Members only supplied for one forecast model. Recycling members for all forecast models.
#> • a
#> ::ensemble point forecast:: # A tibble: 48 × 6
#> fcst_model fcst_dttm lead_time valid_dttm SID a_mbr000
#> <chr> <dttm> <dbl> <dttm> <dbl> <dbl>
#> 1 a 2021-01-01 00:00:00 0 2021-01-01 00:00:00 1001 0.461
#> 2 a 2021-01-01 00:00:00 1 2021-01-01 01:00:00 1001 0.674
#> 3 a 2021-01-01 00:00:00 2 2021-01-01 02:00:00 1001 0.944
#> 4 a 2021-01-01 00:00:00 3 2021-01-01 03:00:00 1001 0.169
#> 5 a 2021-01-01 00:00:00 4 2021-01-01 04:00:00 1001 0.729
#> 6 a 2021-01-01 00:00:00 5 2021-01-01 05:00:00 1001 0.191
#> 7 a 2021-01-01 00:00:00 6 2021-01-01 06:00:00 1001 0.266
#> 8 a 2021-01-01 00:00:00 7 2021-01-01 07:00:00 1001 0.0762
#> 9 a 2021-01-01 00:00:00 8 2021-01-01 08:00:00 1001 0.308
#> 10 a 2021-01-01 00:00:00 9 2021-01-01 09:00:00 1001 0.630
#> # ℹ 38 more rows
#>
#> • b
#> ::ensemble point forecast:: # A tibble: 48 × 6
#> fcst_model fcst_dttm lead_time valid_dttm SID b_mbr000
#> <chr> <dttm> <dbl> <dttm> <dbl> <dbl>
#> 1 b 2021-01-01 00:00:00 0 2021-01-01 00:00:00 1001 0.887
#> 2 b 2021-01-01 00:00:00 1 2021-01-01 01:00:00 1001 0.401
#> 3 b 2021-01-01 00:00:00 2 2021-01-01 02:00:00 1001 0.534
#> 4 b 2021-01-01 00:00:00 3 2021-01-01 03:00:00 1001 0.509
#> 5 b 2021-01-01 00:00:00 4 2021-01-01 04:00:00 1001 0.442
#> 6 b 2021-01-01 00:00:00 5 2021-01-01 05:00:00 1001 0.319
#> 7 b 2021-01-01 00:00:00 6 2021-01-01 06:00:00 1001 0.971
#> 8 b 2021-01-01 00:00:00 7 2021-01-01 07:00:00 1001 0.452
#> 9 b 2021-01-01 00:00:00 8 2021-01-01 08:00:00 1001 0.547
#> 10 b 2021-01-01 00:00:00 9 2021-01-01 09:00:00 1001 0.339
#> # ℹ 38 more rows
#>
# Different members can be selected from each data frame
select_members(ens_point_list, list(a = 0, b = 1))
#> • a
#> ::ensemble point forecast:: # A tibble: 48 × 6
#> fcst_model fcst_dttm lead_time valid_dttm SID a_mbr000
#> <chr> <dttm> <dbl> <dttm> <dbl> <dbl>
#> 1 a 2021-01-01 00:00:00 0 2021-01-01 00:00:00 1001 0.461
#> 2 a 2021-01-01 00:00:00 1 2021-01-01 01:00:00 1001 0.674
#> 3 a 2021-01-01 00:00:00 2 2021-01-01 02:00:00 1001 0.944
#> 4 a 2021-01-01 00:00:00 3 2021-01-01 03:00:00 1001 0.169
#> 5 a 2021-01-01 00:00:00 4 2021-01-01 04:00:00 1001 0.729
#> 6 a 2021-01-01 00:00:00 5 2021-01-01 05:00:00 1001 0.191
#> 7 a 2021-01-01 00:00:00 6 2021-01-01 06:00:00 1001 0.266
#> 8 a 2021-01-01 00:00:00 7 2021-01-01 07:00:00 1001 0.0762
#> 9 a 2021-01-01 00:00:00 8 2021-01-01 08:00:00 1001 0.308
#> 10 a 2021-01-01 00:00:00 9 2021-01-01 09:00:00 1001 0.630
#> # ℹ 38 more rows
#>
#> • b
#> ::ensemble point forecast:: # A tibble: 48 × 6
#> fcst_model fcst_dttm lead_time valid_dttm SID b_mbr001
#> <chr> <dttm> <dbl> <dttm> <dbl> <dbl>
#> 1 b 2021-01-01 00:00:00 0 2021-01-01 00:00:00 1001 0.439
#> 2 b 2021-01-01 00:00:00 1 2021-01-01 01:00:00 1001 0.167
#> 3 b 2021-01-01 00:00:00 2 2021-01-01 02:00:00 1001 0.820
#> 4 b 2021-01-01 00:00:00 3 2021-01-01 03:00:00 1001 0.527
#> 5 b 2021-01-01 00:00:00 4 2021-01-01 04:00:00 1001 0.888
#> 6 b 2021-01-01 00:00:00 5 2021-01-01 05:00:00 1001 0.875
#> 7 b 2021-01-01 00:00:00 6 2021-01-01 06:00:00 1001 0.327
#> 8 b 2021-01-01 00:00:00 7 2021-01-01 07:00:00 1001 0.0630
#> 9 b 2021-01-01 00:00:00 8 2021-01-01 08:00:00 1001 0.755
#> 10 b 2021-01-01 00:00:00 9 2021-01-01 09:00:00 1001 0.349
#> # ℹ 38 more rows
#>
# Deselect members with invert = TRUE
select_members(ens_point_df, 0, invert = TRUE)
#> ::ensemble point forecast:: # A tibble: 48 × 5
#> fcst_dttm lead_time valid_dttm SID point_mbr001
#> <dttm> <dbl> <dttm> <dbl> <dbl>
#> 1 2021-01-01 00:00:00 0 2021-01-01 00:00:00 1001 0.789
#> 2 2021-01-01 00:00:00 1 2021-01-01 01:00:00 1001 0.544
#> 3 2021-01-01 00:00:00 2 2021-01-01 02:00:00 1001 0.454
#> 4 2021-01-01 00:00:00 3 2021-01-01 03:00:00 1001 0.677
#> 5 2021-01-01 00:00:00 4 2021-01-01 04:00:00 1001 0.532
#> 6 2021-01-01 00:00:00 5 2021-01-01 05:00:00 1001 0.107
#> 7 2021-01-01 00:00:00 6 2021-01-01 06:00:00 1001 0.407
#> 8 2021-01-01 00:00:00 7 2021-01-01 07:00:00 1001 0.0583
#> 9 2021-01-01 00:00:00 8 2021-01-01 08:00:00 1001 0.946
#> 10 2021-01-01 00:00:00 9 2021-01-01 09:00:00 1001 0.462
#> # ℹ 38 more rows
select_members(ens_point_list, list(a = 0, b = 1), invert = TRUE)
#> • a
#> ::ensemble point forecast:: # A tibble: 48 × 6
#> fcst_model fcst_dttm lead_time valid_dttm SID a_mbr001
#> <chr> <dttm> <dbl> <dttm> <dbl> <dbl>
#> 1 a 2021-01-01 00:00:00 0 2021-01-01 00:00:00 1001 0.810
#> 2 a 2021-01-01 00:00:00 1 2021-01-01 01:00:00 1001 0.452
#> 3 a 2021-01-01 00:00:00 2 2021-01-01 02:00:00 1001 0.853
#> 4 a 2021-01-01 00:00:00 3 2021-01-01 03:00:00 1001 0.467
#> 5 a 2021-01-01 00:00:00 4 2021-01-01 04:00:00 1001 0.569
#> 6 a 2021-01-01 00:00:00 5 2021-01-01 05:00:00 1001 0.876
#> 7 a 2021-01-01 00:00:00 6 2021-01-01 06:00:00 1001 0.301
#> 8 a 2021-01-01 00:00:00 7 2021-01-01 07:00:00 1001 0.598
#> 9 a 2021-01-01 00:00:00 8 2021-01-01 08:00:00 1001 0.803
#> 10 a 2021-01-01 00:00:00 9 2021-01-01 09:00:00 1001 0.595
#> # ℹ 38 more rows
#>
#> • b
#> ::ensemble point forecast:: # A tibble: 48 × 6
#> fcst_model fcst_dttm lead_time valid_dttm SID b_mbr000
#> <chr> <dttm> <dbl> <dttm> <dbl> <dbl>
#> 1 b 2021-01-01 00:00:00 0 2021-01-01 00:00:00 1001 0.887
#> 2 b 2021-01-01 00:00:00 1 2021-01-01 01:00:00 1001 0.401
#> 3 b 2021-01-01 00:00:00 2 2021-01-01 02:00:00 1001 0.534
#> 4 b 2021-01-01 00:00:00 3 2021-01-01 03:00:00 1001 0.509
#> 5 b 2021-01-01 00:00:00 4 2021-01-01 04:00:00 1001 0.442
#> 6 b 2021-01-01 00:00:00 5 2021-01-01 05:00:00 1001 0.319
#> 7 b 2021-01-01 00:00:00 6 2021-01-01 06:00:00 1001 0.971
#> 8 b 2021-01-01 00:00:00 7 2021-01-01 07:00:00 1001 0.452
#> 9 b 2021-01-01 00:00:00 8 2021-01-01 08:00:00 1001 0.547
#> 10 b 2021-01-01 00:00:00 9 2021-01-01 09:00:00 1001 0.339
#> # ℹ 38 more rows
#>