Skip to contents

Find the date of the last observation (NAs are dropped)

Usage

find_end(x, last_day = FALSE)

Arguments

x

ts-boxable object

last_day

should the last day of period be returned (default: FALSE)

Value

date associated with last observation

Examples

quarterly_data_example |>
  dplyr::mutate(E_NF_HI = dplyr::if_else(time > "2022-01-01", NA_real_, E_NF_HI)) |>
  find_end()
#>  [1] "2022-01-01" "2025-01-01" "2025-01-01" "2025-01-01" "2025-01-01"
#>  [6] "2025-01-01" "2025-01-01" "2025-01-01" "2025-01-01" "2025-01-01"
#> [11] "2025-01-01" "2025-01-01" "2025-01-01" "2025-01-01" "2025-01-01"
#> [16] "2025-01-01" "2025-01-01" "2025-01-01" "2025-01-01" "2025-01-01"
#> [21] "2025-01-01" "2025-01-01" "2025-01-01" "2025-01-01" "2025-01-01"
#> [26] "2025-01-01" "2025-01-01" "2025-01-01" "2025-01-01" "2025-01-01"
quarterly_data_example |>
  dplyr::mutate(E_NF_HI = dplyr::if_else(time > "2022-01-01", NA_real_, E_NF_HI)) |>
  find_end(TRUE)
#>  [1] "2022-03-31" "2025-03-31" "2025-03-31" "2025-03-31" "2025-03-31"
#>  [6] "2025-03-31" "2025-03-31" "2025-03-31" "2025-03-31" "2025-03-31"
#> [11] "2025-03-31" "2025-03-31" "2025-03-31" "2025-03-31" "2025-03-31"
#> [16] "2025-03-31" "2025-03-31" "2025-03-31" "2025-03-31" "2025-03-31"
#> [21] "2025-03-31" "2025-03-31" "2025-03-31" "2025-03-31" "2025-03-31"
#> [26] "2025-03-31" "2025-03-31" "2025-03-31" "2025-03-31" "2025-03-31"