build_tsibble()
creates a tbl_ts
object with more controls. It is useful
for creating a tbl_ts
internally inside a function, and it allows developers to
determine if the time needs ordering and the interval needs calculating.
build_tsibble(
x,
key = NULL,
key_data = NULL,
index,
index2 = index,
ordered = NULL,
interval = TRUE,
validate = TRUE,
.drop = key_drop_default(x)
)
A data.frame
, tbl_df
, tbl_ts
, or other tabular objects.
Variable(s) that uniquely determine time indices. NULL
for
empty key, and c()
for multiple variables. It works with tidy selector
(e.g. dplyr::starts_with()
).
A data frame containing key variables and .rows
. When a data
frame is supplied, the argument key
will be ignored.
A variable to specify the time index variable.
A candidate of index
to update the index to a new one when
index_by. By default, it's identical to index
.
The default of NULL
arranges the key variable(s) first and
then index from past to future. TRUE
suggests to skip the ordering as x
in
the correct order. FALSE
checks the ordering and may give a warning.
TRUE
automatically calculates the interval, and FALSE
for
irregular interval. Use the specified interval via new_interval()
as is.
TRUE
suggests to verify that each key or each combination
of key variables leads to unique time indices (i.e. a valid tsibble). If you
are sure that it's a valid input, specify FALSE
to skip the checks.
If TRUE
, empty key groups are dropped.
# NOT RUN {
# Prepare `pedestrian` to use a new index `Date` ----
pedestrian %>%
build_tsibble(
key = !!key_vars(.), index = !!index(.), index2 = Date,
interval = interval(.)
)
# }
Run the code above in your browser using DataLab