There is time series ttrc_total , when applying the dplyr function group_by mutate ..., there are failures. Is there way to solve it? Thanks!
library(TTR)
library(tidyverse)
data(ttrc)
ttrc_total <- rbind(ttrc %>% mutate(category='A'),
ttrc %>% mutate(category='B'),
ttrc %>% mutate(category='C'))
Below code show error message : no applicable method for 'group_by' applied to an object of class "c('xts', 'zoo')"
ttrc_total %>% xts::xts(., order.by=.$Date) %>%
group_by(category) %>%
mutate(ATR_10 = ATR(.[,c("High","Low","Close")], n=10))
I might try to split the data by category and shape it back to long format.
Created on 2023-09-01 with reprex v2.0.2