run_by | R Documentation |
Set window parameters for runner()
. This function sets the
attributes to x
(only data.frame
) object and saves user effort
to specify window parameters in further multiple runner()
calls.
run_by(x, idx, k, lag, na_pad, at)
x |
( |
idx |
( |
k |
( |
lag |
( |
na_pad |
( |
at |
( |
x object which runner()
can be executed on.
## Not run:
library(dplyr)
data <- data.frame(
index = c(2, 3, 3, 4, 5, 8, 10, 10, 13, 15),
a = rep(c("a", "b"), each = 5),
b = 1:10
)
data %>%
group_by(a) %>%
run_by(idx = "index", k = 5) %>%
mutate(
c = runner(
x = .,
f = function(x) {
paste(x$b, collapse = ">")
}
),
d = runner(
x = .,
f = function(x) {
sum(x$b)
}
)
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.