Open
Description
In zoo rollapply can have a list as width argument to specify offsets like:
z <- data.frame(date=as.Date(1:10),
x=1:10)
data.frame(dates=z$date,
rollapply(z$x,by.column=TRUE,
list(-3:-5) ,
mean,
fill=NA))
which calculates the mean of element 3 to 5 position before.
With tq_mutate
z %>%
tq_mutate(
select = x,
mutate_fun = rollapply,
width = list(-3:-5),
FUN = mean)
Error in rollapply.xts(., ...) :
'list' object cannot be coerced to type 'integer'
it seems that the rollapply.xts does not support width = list() while the rollapply.zoo does. Is there an option to use the zoo version of rollaply with tq_mutate or get an offset in some other way?
Metadata
Assignees
Labels
No labels
Activity