'summarise function is not grouping the data by groups when used with group_by()

I have a large dataset with COVID-19 cases, with number of cases per for each date.This data is in the dat dataframe. I am trying to summarize these data by a variable which contains ID of all districts and the date variable (Meldedatum), for some reason the output in new data frame is just 1 row with total cases for the entire period and it is not grouped by ID and date variable. I dot know why that is. I am adding screen shot of the dataset to show what it looks like. Can someone help?

sample of data. There are more than 100,000 observations in total for 44 districts, I am just including sample with 2 different districts and dates.

dat<-data.frame(Landkreis=c("Sk Stuttgart", "Sk Stuttgart", "Lk Freiburg","Lk Freiburg"),
              Anzahlfall=c(1,1,1,1),AnzahlTodesfall=c(0,1,2,1),
          Meldedatum=c("09-03-2020","18-03-2020","09-03-2020","20-03-2020"),IdLandkreis=c(8111, 8111,8116,8116))

enter image description here

datAggMelde <- dat %>% group_by(IdLandkreis,  Meldedatum) %>%
  summarize(sumCount = sum(AnzahlFall, na.rm = TRUE),
            sumDeath = sum(AnzahlTodesfall, na.rm = TRUE),
            Landkreis = first(Landkreis) )


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source