ts_to_df: Convert time series to tibble

View source: R/converters.R

ts_to_dfR Documentation

Convert time series to tibble

Description

Converts a ts object into a tibble with two columns: date and value. Optionally, the columns can be renammed using date_col and value_col.

Usage

ts_to_df(x, date_col = NULL, value_col = NULL)

Arguments

x

A time series as a ts object

date_col

Name for the date column. Defaults to '"date"“.

value_col

Name for the value column. Defaults to "value".

Value

a tibble

Examples

# example code
ts_to_df(AirPassengers)

# Using a custom name for the value column
ts_to_df(AirPassengers, value_col = "passengers")

trendseries documentation built on Oct. 1, 2026, 5:10 p.m.