structure(list(ReviewType= c("Primary", "Secondary", "Secondary", "Primary", "Secondary"), Submissiondate= c("2020-09-04", "2020-09-03","2020-09-02","2020-09-01","2020-08-31" ),Channel= c("OC", "BC","BC","BC","PK" )), class = "data.frame", row.names = c(NA, -5L))
I have a query below and others too that i would like to edit such that instead of giving me the week number, it tells me the date range of that week:
FinalCounting<-Out %>%
group_by(Year = year(Submissiondate), Week = week(Submissiondate)) %>%
summarise(Primary = sum(ReviewType == "Primary"),
Secondary = sum(ReviewType == "Secondary"))
When the query is run, it gives out a output like this:
If instead of 36, i get 2020-08-31 - 2020-09-04 or even just the last date of this range so i can call it As of Reporting date, is that possible? Any help is appreciated.
Just create a column with Week = paste(lubridate::floor_date(Submissiondate, unit = "weeks"), "-", lubridate::ceiling_date(Submissiondate, unit = "weeks"))
.
You should be able to put this right into the group_by
statement or into a mutate
before (for a little more readability).