I have to make a time series on iso-calendar weeks. My data are given on a daily basis. I want to aggregate them on ISO calendar week level over the respective product groups. However, I want to have the calendar week and the year in the data and format this as date or POSIXct so that I can create a time series afterwards.
Summarized:
Date (d-m-y) -> Isoweek/year as a new column but formated as.date --> Create time series (frequency 52) per product group (both individually and one large one for all)
My previous attempts have not worked:
data2 <- data %>%
mutate(new_date=as.Date(KW, format="%W"), new_date2=year(Date))
data3 <- data %>%
mutate(new_date=isoweek(date), new_date2=year(date))
Thank you very much for your help.
Enclosed you will find an excerpt from my data so that you can understand the structure.
Fixed it thanks.
But it still only gives me the isoweek. It needs to include the year of the week as well. And its format is still num whereas I need date or POSIXct to make a ts() out of it. I am sorry about that many questions. Do you have a solution for that as well?