lag_df2 | R Documentation |
The lag_df2
function creates additional columns based on a list of column names
and lag sequences. This feature is beneficial for scenarios where you need
varying lag selections for certain columns, allowing flexibility in specifying
different lags for different columns or opting for no lag at all.
lag_df2(df, laglist)
df |
A data.frame or tibble. |
laglist |
A list of column names where each index corresponds to a column name and the associated value is the lag sequence. |
data.frame
df <- data.frame(a = 1:15, b = 2:16)
df2 <- lag_df2(df, laglist = list(a = 1:5, b = 1:3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.