Open
Description
Good morning,
I have been using the excellent fabletools package and I would like to know how to specify a linear combination in a hierarchical time series when using the aggregate_key function. In this simple reproducible example that I simulated I would like to have a TOTAL that is just 0.5FOOD+0.5CORE. Here I post the code:
library(fpp3)
FOOD<-rnorm(100)
CORE<-rnorm(100)
DATE<-yearmonth(seq.Date(from=as.Date("2001-01-01"),by="months",length.out = 100))
DF1<-as_tsibble(tibble(DATE,CORE,FOOD),index="DATE") %>%
pivot_longer(cols = c("CORE","FOOD"),names_to="COMPONENT") %>%
rename(INDEX=value)
DF1 %>%
aggregate_key(COMPONENT,INDEX=sum(INDEX))
#######
I would appreciate any comment.
Thank you very much.
Metadata
Assignees
Labels
No labels