# NOT RUN {
.x <- 1:5
.y <- 6:10
.z <- 11:15
.lst <- list(x = .x, y = .y, z = .z)
.df <- as.data.frame(.lst)
slide2(.x, .y, sum, .size = 2)
slide2(.lst, .lst, ~ ., .size = 2)
slide2(.df, .df, ~ ., .size = 2)
pslide(.lst, ~ ., size = 1)
pslide(list(.lst, .lst), ~ ., .size = 2)
## window over 2 months
pedestrian %>%
filter(Sensor == "Southern Cross Station") %>%
index_by(yrmth = yearmonth(Date_Time)) %>%
nest(-yrmth) %>%
mutate(ma = slide_dbl(data, ~ mean(do.call(rbind, .)$Count), .size = 2))
# row-oriented workflow
# }
# NOT RUN {
my_diag <- function(...) {
data <- list(...)
fit <- lm(data$Count ~ data$Time)
tibble::tibble(fitted = fitted(fit), resid = residuals(fit))
}
pedestrian %>%
filter(Date <= as.Date("2015-01-31")) %>%
nest(-Sensor) %>%
mutate(diag = purrr::map(data, ~ pslide_dfr(., my_diag, .size = 48)))
# }
Run the code above in your browser using DataLab