check_key: Check on key when create cubble from two components...

View source: R/check-key.R

check_keyR Documentation

Check on key when create cubble from two components (spatial/temporal)

Description

When creating a cubble from separate spatial and temporal component, make_cubble() will informed users about potential disagreement of the key values in the two datasets (some sites appear in one table but not the other). This function summarises the key values into those match, potentially can be matched, and can't be matched.

Usage

check_key(spatial, temporal, by = NULL)

Arguments

spatial

a tibble object or an sf object, the spatial component containing the key and coords variable (coords can be automatically created from an sf object if not supplied).

temporal

a tibble object or a tsibble object, the temporal component containing the key and index variable.

by

in the syntax of the by argument in dplyr::left_join(), used in make_cubble() when the key variable has different names in the spatial and temporal data.

Value

a list with three elements: 1) paired: a tibble of paired ID from spatial and temporal data, 2) potential_pairs: a tibble of pairs that could potentially match from both datasets, 3) others: other key values that can't be matched in a list: others$temporal and others$spatial

Examples

check_key(stations, meteo)

# make_cubble() will prompt to use check_key if there are key mis-match:
colnames(lga) <- c("lga", "geometry")
cb <- make_cubble(spatial = lga, temporal = covid)
(check_res <- check_key(lga, covid))
make_cubble(spatial = lga, temporal = covid, potential_match = check_res)

cubble documentation built on Sept. 11, 2024, 7:19 p.m.