I have this data.frame:
structure(list(Date = structure(c(1609027200, 1609027200, 1609027200, 1609027200, 1609027200, 1609027200),
tzone = "UTC", class = c("POSIXct", "POSIXt")),
Type = c("In Store", "In Store", "In Store", "In Store", "In Store", "In Store"),
Method = c("Roadie", "Roadie", "Roadie", "Roadie", "Roadie", "Roadie"),
`Category Full` = c("SAFES", "WOOD PELLETS", "FEEDLOT PANELS", "S&H OR HOME DELIVERY", "T-POSTS", "S&H OR HOME DELIVERY" ),
Week = c(52, 52, 52, 52, 52, 52)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))
My code is this:
res02 <- d %>%
select(Date, Method, Category_Full ='Category Full') %>%
mutate(Week = week(Date)) %>%
group_by(Week, Category_Full) %>%
mutate(Category_Count = nchar(Category_Full))
I am trying to find the top 5 $Category_Full
base on $Method
for each Week of the year. The Week Column lists 1:52. I tried using nchar
and summarise
but I can't get this to work
The Excel sheet would be similar end result