Given:
test <- tsibble(
date = lubridate::now() + 0:9,
value = rnorm(10)
) %>%
mutate (vdiff =diff(value, differences = 2))
How do I avoid the following :
Error: Problem with
mutate()
columnvdiff
. ℹvdiff = diff(value, differences = 2, na.pad = TRUE)
. ℹvdiff
must be size 10 or 1, not 8
I tried adding na.pad = TRUE
but that has no effect (and in any event, I would prefer to pad with 0
not NA
)