Learn R Programming

tsibble (version 1.2.0)

index: Return index variable from a tsibble

Description

Return index variable from a tsibble

Usage

index(x)

index_var(x)

index2(x)

index2_var(x)

Arguments

x

A tsibble object.

Details

index() returns a symbol; index_var() gives a character string.

When used inside tidyverse functions like dplyr::select(), dplyr::relocate(), or other tidyselect-compatible functions, index_var() acts as a selection helper that automatically selects the index column from the tsibble.

Examples

Run this code
index(pedestrian)
index_var(pedestrian)

# Use as a tidyselect helper
library(dplyr)
tourism %>% select(index_var(), key_vars())

# Use with relocate
tourism %>% relocate(index_var(), .after = key_vars())

Run the code above in your browser using DataLab