Skip to contents

Read-only queries on the timeframe hierarchy of a Calendar — the time-side mirror of geoscales::geoscale_geoframes() and friends.

Usage

# S3 method for class 'Calendar'
names(x)

calendar_timeframes(x, finest = FALSE)

calendar_rank(x, timeframe)

calendar_timeslices(x, timeframe = NULL)

Arguments

x

A Calendar.

finest

calendar_timeframes() only: return just the finest timeframe (the leaf layer) instead of the full ordered vector — the twin of geoscales::geoscale_geoframes(x, finest = TRUE).

timeframe

A timeframe name (see calendar_timeframes()).

Value

calendar_timeframes() and calendar_timeslices() return a character vector; calendar_rank() an integer.

Details

  • calendar_timeframes() — hierarchy names, coarsest first.

  • calendar_rank() — position of a timeframe (1 = coarsest); NA for unknown names.

  • calendar_timeslices() — with a timeframe, its members in canonical order: the nodes of the hierarchy at that timeframe (m01 at MONTH, m01_h00 at HOUR), which are the leaf timeslices of prune_calendar(x, timeframe). Without, the leaf timeslices.

  • names() on a Calendar returns the timeframe names (identical to calendar_timeframes()), NOT the leaftable column names.

Examples

cal <- calendar("q4_h24")
calendar_timeframes(cal)
#> [1] "QUARTER" "HOUR"   
calendar_rank(cal, "HOUR")
#> [1] 2
calendar_timeslices(cal, "QUARTER")
#> [1] "Q1" "Q2" "Q3" "Q4"
head(calendar_timeslices(cal, "HOUR"))
#> [1] "Q1_h00" "Q1_h01" "Q1_h02" "Q1_h03" "Q1_h04" "Q1_h05"