mutate_delta | R Documentation |
This function will create a delta variable given a subject id, variable name and dataframe. It will also skip NA values in the calculation of the delta.
mutate_delta(
data,
cols,
id,
time,
fill = 0,
n = 1L,
type = "lag",
prefix = paste("delta", type, n, sep = "_")
)
data |
the dataframe to be called |
cols |
the character string or character vector of columns to apply this function to |
id |
a character string specifying the name of the id variable |
time |
a character stirng the time variable |
fill |
numeric or NA to specifying what to fill the values that fall outside the offset window. For example, if we ar taking lagged differences, this will set the value of the firt observation. |
n |
number of steps to alter rolling difference window |
type |
character string whether lead or lag should be used |
prefix |
a character string denothing the prefix of the delta column. The column name for the new delta column will be "prefix_oldname" |
Jorge Martinez Romero, William Mueller
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.