Converts a series, stored in a data.frame or tibble, into a ts object.
Usage
df_to_ts(x, date_col = "date", value_col = "value", frequency = 12)
Arguments
- x
A data.frame, tibble or data.table.
- date_col
Name of the date column. Defaults to 'date'. Must be of class Date.
- value_col
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
ibc <- df_to_ts(ibcbr, value_col = "index", frequency = "M")
class(ibc)
#> [1] "ts"
plot(ibc)