Hi, I have a dataset that looks like this
store week year
1 1 2017
1 2 2017
1 1 2018
1 2 2018
1 1 2019
1 2 2019
2 1 2017
2 2 2017
2 1 2018
2 2 2018
1 1 2019
1 2 2019
My goal is to unifiy that week variable so that i won't need my year variable anymore, i want for each store the week number to be 1 - 2 (for 2017)- 3 - 4(for 2018) - 5 - 6(for 2019)
well I succeeded in doing that, but i'm absolutely not statisfied, I would like to know if there a more automatized and better way to do it
Here is my code :
data_c4_0 = data_c6 %>% dplyr::filter(year==2017)
data_c4_1 = data_c6 %>% dplyr::filter(year==2018) %>% mutate(week = week + 2)
data_c4_2 = data_c6 %>% dplyr::filter(year==2019) %>% mutate(week = week + 4)
data_c44 = rbind(data_c4_0,data_c4_1)
data_c6 = rbind(data_c44,data_c4_2)
Thanks in advance