Get names of columns that form a (unique) key associated with an object
Source:R/key_colnames.R
key_colnames.Rd
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 forepi_df
s,epi_archive
s,tsibble::tsibble
s, and other data frames (includingtibble::tibble
s); 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 inx
, and time interval during which associated events occurred.Mandatory if
x
is a regulardata.frame
ortibble
. Optional ifx
is anepi_df
; the defaults are"geo_value"
, theepi_df
'sother_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 whetherx
is anepi_df
or just atibble
/data.frame
. You don't need to use it if you know thatx
is definitely anepi_df
.) Not accepted whenx
is atsibble
or anepi_archive
.