key_colnames: Get names of columns that form a (unique) key associated with...

View source: R/key_colnames.R

key_colnamesR Documentation

Get names of columns that form a (unique) key associated with an object

Description

This is entirely based on metadata and arguments passed; there are no explicit checks that the key actually is unique in any associated data structures.

Usage

key_colnames(x, ..., exclude = character())

## S3 method for class 'data.frame'
key_colnames(x, ..., geo_keys, other_keys, time_keys, exclude = character())

## S3 method for class 'epi_df'
key_colnames(
  x,
  ...,
  geo_keys = "geo_value",
  other_keys = attr(x, "metadata")$other_keys,
  time_keys = "time_value",
  exclude = character()
)

## S3 method for class 'tbl_ts'
key_colnames(x, ..., exclude = character())

## S3 method for class 'epi_archive'
key_colnames(x, ..., exclude = character())

Arguments

x

an object, often a data frame or something similar. {epiprocess} includes implementations for epi_dfs, epi_archives, tsibble::tsibbles, and other data frames (including tibble::tibbles); other packages, like {epipredict}, can add more.

...

additional arguments passed on to methods

exclude

an optional character vector of key column names to exclude from the result

geo_keys, other_keys, time_keys

character vectors, sometimes optional; which variables (if any) should be considered as part of a unique key/identifier for data in x, dealing respectively with the associated geographical region, demographic/strain/other information needed in addition to the geographical region to identify individual time series in x, and time interval during which associated events occurred.

Mandatory if x is a regular data.frame or tibble. Optional if x is an epi_df; the defaults are "geo_value", the epi_df's other_keys metadata, and "time_value", respectively; if you provide these manually, they must match the defaults. (This behavior is to enable consistent and sane results when you can't guarantee whether x is an epi_df or just a tibble/data.frame. You don't need to use it if you know that x is definitely an epi_df.) Not accepted when x is a tsibble or an epi_archive.

Value

character vector


cmu-delphi/epiprocess documentation built on Feb. 22, 2025, 9:26 a.m.