| df_to_ts | R Documentation |
Converts a series, stored in a data.frame or tibble, into a ts object.
A ts positions observations by period rather than by date, so the input
must cover a complete run of periods. Rows are sorted before conversion, and
a missing or duplicated period is rejected rather than silently shifting
every later observation onto the wrong date. Missing values are kept in
place, which leaves the series correctly dated.
df_to_ts(x, date_col = "date", value_col = "value", frequency = 12)
x |
A |
date_col |
Name of the date column. Defaults to |
value_col |
Name of the value column. Defaults to |
frequency |
The frequency of the series. Can be a shortened string (e.g. "M" for monthly) or a number (e.g. 12). |
A ts object
ibc <- df_to_ts(ibcbr, value_col = "index", frequency = "M")
class(ibc)
plot(ibc)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.