Hello,
I have a tsibble with monthly data and I want to convert it to quarterly data. I am not sure where I am going wrong. Thanks for your help!
df <- data.frame(
date = c("1996 Jan",
"1996 Feb","1996 Mar","1996 Apr","1996 May",
"1996 Jun","1996 Jul","1996 Aug","1996 Sep",
"1996 Oct","1996 Nov","1996 Dec","1997 Jan",
"1997 Feb","1997 Mar","1997 Apr","1997 May",
"1997 Jun","1997 Jul","1997 Aug","1997 Sep",
"1997 Oct","1997 Nov","1997 Dec"),
sales = c(376,393,524,
525,544,516,428,451,484,481,407,453,
484,468,584,583,594,578,546,570,710,622,
547,722)
)
df <- df %>%
mutate(date = yearquarter(date))%>%
#as_tsibble(index = date)%>%
group_by(yearquarter(date))%>%
summarise(sales = sum(sales))