Learn R Programming

tsibble (version 0.5.2)

key: Return key variables

Description

key() returns a list of symbols; key_vars() gives a character vector.

Usage

key(x)

key_vars(x)

unkey(x)

Arguments

x

A data frame.

Examples

Run this code
# NOT RUN {
# A single key for pedestrian data ----
key(pedestrian)
key_vars(pedestrian)

# Nested and crossed keys for tourism data ----
key(tourism)
key_vars(tourism)
# unkey() only works for a tsibble with 1 key size ----
sx <- pedestrian %>%
  filter(Sensor == "Southern Cross Station")
unkey(sx)
# }

Run the code above in your browser using DataLab