| check_data | R Documentation |
Check that the input data is a valid regular and ordered tsibble, fill
implicit gaps if requested, and convert wide data to long format.
check_data(data, fill_missing = TRUE)
data |
A |
fill_missing |
Logical value. If |
check_data() is a data preparation helper for time series workflows.
It performs three tasks:
checks that data is a tsibble;
checks that the time index is regular and ordered by key and index;
optionally turns implicit missing values into explicit missing values
using fill_gaps().
If the input data has no key variables, it is treated as wide data and is
converted to long format. The resulting output contains the original index
column, a variable column containing the former column names, and a
value column containing the corresponding observations.
Existing explicit missing values are not changed.
A tsibble prepared for downstream use. Wide data is returned in long
format with one measurement variable named value.
Other data preparation:
interpolate_missing(),
smooth_outlier()
library(dplyr)
library(tsibble)
data <- M4_monthly_data |>
filter(series %in% c("M23100", "M14395")) |>
as_tsibble(
index = index,
key = series
)
check_data(data)
wide_data <- data |>
as_tibble() |>
select(index, series, value) |>
tidyr::pivot_wider(
names_from = series,
values_from = value
) |>
as_tsibble(index = index)
check_data(wide_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.