Skip to contents

Members related to the selected members across timeframes — the time-side mirror of geoscales::geoscale_children() and friends. Members are nodes of the hierarchy (m01 at MONTH, m01_h00 at HOUR), so these are exact partitions: the parent of m01_h00 at MONTH is m01, and the children of m01 at HOUR are its 24 hours.

Usage

calendar_children(
  x,
  timeframe,
  timeslice = NULL,
  target = NULL,
  token = NULL,
  to = lifecycle::deprecated()
)

calendar_parents(
  x,
  timeframe,
  timeslice = NULL,
  target = NULL,
  token = NULL,
  to = lifecycle::deprecated()
)

calendar_descendants(
  x,
  timeframe,
  timeslice = NULL,
  target = NULL,
  token = NULL,
  to = lifecycle::deprecated()
)

calendar_ancestors(
  x,
  timeframe,
  timeslice = NULL,
  target = NULL,
  token = NULL,
  to = lifecycle::deprecated()
)

Arguments

x

A Calendar.

timeframe

The timeframe the selected members live at.

timeslice

One or more members of timeframe, by name.

target

Optional target timeframe; defaults to the adjacent one (children/parents) or the full transitive range (descendants/ancestors).

token

One or more token labels of timeframe ("h00"); selects every member carrying one of them (hour 0 of every month). Give timeslice or token, not both; token on a timeframe without a token is an error.

to

Deprecated name of target.

Value

calendar_children() / calendar_parents() return a character vector of members; calendar_descendants() / calendar_ancestors() a data.frame(timeframe, timeslice).

Details

  • calendar_children() — one step finer (or at target).

  • calendar_parents() — one step coarser (or at target).

  • calendar_descendants() — all finer timeframes (down to target).

  • calendar_ancestors() — all coarser timeframes (up to target).

Examples

cal <- calendar("q4_h24")
calendar_children(cal, "QUARTER", "Q1")
#>  [1] "Q1_h00" "Q1_h01" "Q1_h02" "Q1_h03" "Q1_h04" "Q1_h05" "Q1_h06" "Q1_h07"
#>  [9] "Q1_h08" "Q1_h09" "Q1_h10" "Q1_h11" "Q1_h12" "Q1_h13" "Q1_h14" "Q1_h15"
#> [17] "Q1_h16" "Q1_h17" "Q1_h18" "Q1_h19" "Q1_h20" "Q1_h21" "Q1_h22" "Q1_h23"
calendar_parents(cal, "HOUR", "Q1_h00")
#> [1] "Q1"
calendar_parents(cal, "HOUR", token = "h00")
#> [1] "Q1" "Q2" "Q3" "Q4"