matchyear: Match the year between the dataset of interest and another...

View source: R/matchyear.R

matchyearR Documentation

Match the year between the dataset of interest and another data source

Description

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.

Usage

matchyear(
  data,
  data_tomatch,
  match = c("exact", "closest", "recent", "soonest"),
  year = NULL
)

Arguments

data

Tabular object (e.g. data.frame, sf, tibble) containing the data.

data_tomatch

Tabular object (e.g. data.frame, sf, tibble) to match the data to.

match

Type of matching; either 'exact', 'closest', 'recent' or 'soonest'.

year

Specify column name for the year within both datasets. Columns in both datasets should be numeric.

Value

data with additional column year_match, representing the matching year of the other dataset.


ecological-cities/home2park documentation built on Dec. 6, 2023, 1:05 a.m.