Description Usage Arguments Details Value See Also Examples
View source: R/step_lag_matrix.R
'step_lag_matrix' creates a *specification* of a recipe step that will add new columns of lagged data. Lagged data will by default include NA values where the lag was induced. These can be removed with [step_naomit()], or you may specify an alternative filler value with the 'default' argument. This method is faster than [step_lag()] and allows for negative values.
1 2 3 4 |
recipe |
A recipe object. The step will be added to the sequence of operations for this recipe. |
... |
One or more selector functions to choose which variables are affected by the step. See [selections()] for more details. |
role |
Defaults to "predictor" |
trained |
A logical to indicate if the quantities for preprocessing have been estimated. |
lag |
A vector of integers. They can be positive, negative or zero. Each specified column will be lagged for each value in the vector. |
n_subset |
subset every n_subset values |
n_shift |
shift the data n_shift values |
prefix |
A prefix for generated column names, default to "lag_". |
default |
Passed to |
columns |
A character string of variable names that will be populated (eventually) by the 'terms' argument. |
skip |
A logical. Should the step be skipped when the recipe is baked by [bake.recipe()]? While all operations are baked when [prep.recipe()] is run, some operations may not be able to be conducted on new data (e.g. processing the outcome variable(s)). Care should be taken when using 'skip = TRUE' as it may affect the computations for subsequent operations |
id |
A character string that is unique to this step to identify it. |
The step assumes that the data are already _in the proper sequential order_ for lagging.
An updated version of 'recipe' with the new step added to the sequence of existing steps (if any).
[recipe()] [step_lag()] [prep.recipe()] [bake.recipe()] [step_naomit()]
1 2 3 4 5 6 7 8 9 10 | data(transducer)
rec <- recipe(wl ~ .,
data = transducer[1:1000, list(datetime, wl, baro)])
with_et <- rec %>%
step_lag_matrix(baro, lag = -1:1) %>%
step_naomit(everything()) %>%
prep() %>%
juice()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.