R/matchyear.R
matchyear.Rd
Helper function to match the year in the data with either the (1) exact; (2) most recent (past); (3) closest (past or future); or (4) soonest (future) year in another dataset. The column name within both datasets that represent the year must be specified. Dataset containing multiple years must be in the 'long' format.
matchyear(
data,
data_tomatch,
match = c("exact", "closest", "recent", "soonest"),
year = NULL
)
Tabular object (e.g. data.frame
, sf
, tibble
) containing the data.
Tabular object (e.g. data.frame
, sf
, tibble
) to match the data to.
Type of matching; either 'exact'
, 'closest'
, 'recent'
or 'soonest'
.
Specify column name for the year within both datasets. Columns in both datasets should be numeric.
data
with additional column year_match
,
representing the matching year of the other dataset.