Learn R Programming

trendseries (version 1.1.0)

df_to_ts: Convert a data.frame into a time series (ts)

Description

Converts a series, stored in a data.frame or tibble, into a ts object.

Usage

df_to_ts(x, date_colname = "date", value_colname = "value", frequency = 12)

Value

A ts object

Arguments

x

A data.frame, tibble or data.table.

date_colname

Name of the date column. Defaults to 'date'. Must be of class Date.

value_colname

Name of the value column. Defaults to 'value'. Must be numeric.

frequency

The frequency of the series. Can be a shortened string (e.g. "M" for monthly) or a number (e.g. 12).

Examples

Run this code
ibc <- df_to_ts(ibcbr, value_colname = "index", frequency = "M")
class(ibc)
plot(ibc)

Run the code above in your browser using DataLab