Skip to contents

Materialises the A -> base -> B route as a table: for the requested model year(s), one row per pair of overlapping timeslices with

Usage

calendar_map_between(
  source,
  target,
  year,
  by = NULL,
  tz = "UTC",
  from = lifecycle::deprecated(),
  to = lifecycle::deprecated()
)

Arguments

source, target

Calendar objects (both must be named).

year

Integer vector of model year(s); multi-year maps carry all years in the year column.

by

Grid resolution (seq.POSIXt step). Default: the finest timeframe of the two calendars.

tz

Time zone of the grid. Default "UTC".

from, to

Deprecated names of source and target.

Value

A data.frame with columns year, <source name>, <target name> (NA = uncovered by target), n_from, n_overlap, w.

Details

  • n_from – grid points in the source timeslice (its full set, before any target coverage is considered),

  • n_overlap – grid points the pair shares,

  • w – the weight of the overlap (leaves$total[from] * n_overlap / n_from, with total the part of the year the source timeslice stands for), the quantity "weighted_mean" aggregation uses.

A timeslice of the source that is left out (weight 0) stands for nothing and has no row: its grid points are no part of the crosswalk.

The two label columns are named by the calendars' names (so the map joins directly onto datasets labelled by join_calendar()); rows with an NA target label are grid points target does not cover. A crosswalk registered with register_calendar_map_between() is returned as-is instead of being derived from the grid.

See also

calendar_map() for the map between two timeframes of one calendar.

Examples

m12 <- calendar_build("m12")
q4  <- calendar_build("q4")
calendar_map_between(m12, q4, year = 2021)
#>    year m12 q4 n_from n_overlap          w
#> 1  2021 m01 Q1     31        31 0.08493151
#> 2  2021 m02 Q1     28        28 0.07671233
#> 3  2021 m03 Q1     31        31 0.08493151
#> 4  2021 m04 Q2     30        30 0.08219178
#> 5  2021 m05 Q2     31        31 0.08493151
#> 6  2021 m06 Q2     30        30 0.08219178
#> 7  2021 m07 Q3     31        31 0.08493151
#> 8  2021 m08 Q3     31        31 0.08493151
#> 9  2021 m09 Q3     30        30 0.08219178
#> 10 2021 m10 Q4     31        31 0.08493151
#> 11 2021 m11 Q4     30        30 0.08219178
#> 12 2021 m12 Q4     31        31 0.08493151