Hi ! My first question here
Actually i have created these factors :
df$period <- cut(df$temps_diffusion, c(0, 7, 14, 30, 90, 180, 360, Inf),
labels = c("j+7", "j+14", "j+30", "j+90", "j+180","j+360", "j+inf"), right = FALSE)
And i made a group_by on these factors
df= df%>% group_by(idproduit,datediffusion,period) %>% summarise(., across(where(is.numeric), sum))
This is a part of my result :
idproduit datediffusion period vues_hors_robots
1 6539665 2022-10-06 j+7 279
2 6539665 2022-10-06 j+14 351
3 6539665 2022-10-06 j+30 399
(There is just 3 rows of result)
I would know if it's possible to let each modality i created even if they have no data.
In order to have this result :
idproduit datediffusion period vues_hors_robots
1 6539665 2022-10-06 j+7 279
2 6539665 2022-10-06 j+14 351
3 6539665 2022-10-06 j+30 399
4 6539665 2022-10-06 j+90 NA
5 6539665 2022-10-06 j+180 NA
6 6539665 2022-10-06 j+360 NA
......
Thanks for your help