NSO tables label periods in several formats, such as "2024",
"2024-03", "2016M3", "2024.03", "2024-I" (first quarter) or
"2026-07-06". nso_period_date() returns the first day of each period,
so results can be sorted, filtered and plotted on a date axis. A trailing
*, which NSO uses to mark preliminary figures, is ignored.
Arguments
- x
A character vector of period labels, such as the time column returned by
nso_data().
Value
A Date vector the same length as x holding the first day of
each period. Labels that are not periods, such as "Total", give NA.
Details
NSO's quarterly tables label quarters "2025-1" to "2025-4". When every
label in x has that form, x is read as quarters; otherwise "2025-4"
is April. Pass a table's whole time column so this can be decided, or see
the frequency column of nso_table_periods().
See also
nso_table_periods() for the periods available in a table.
Examples
nso_period_date(c("2024", "2024-03", "2016M3", "2024-II", "Total"))
#> [1] "2024-01-01" "2024-03-01" "2016-03-01" "2024-04-01" NA