'How to collapse/sum-up a data-frame by not needed subpopulation variables in R? [duplicate]
Screenshot: raw data-frame organization of COVID-Cases in Germany

I downloaded the notified COVID-Cases in Germany from an official website. This raw data-frame is organized by the following columns (see also screenshot): "IdCounty", "NameCounty", "DateNotification", "AgeGroup", "Gender", "FreqCases".
What is a clever way in R to collapse/re-arrange/sum-up this raw data-frame by all categories in "AgeGroup" and "Gender", i.e. so this two subpopulation-breakdown variables will disappear, i.e. are collapsed ? Reason: I want to do analyses of the COVID-Cases by counties and time-points, but I don't want to differentiate further by age nor gender, i.e. just take all ages and all genders as sums together.
I struggled with various functions to achieve this, but I am pretty sure there is a smart & clever way to do this quite easily.
Solution 1:[1]
library(tidyverse)
data <- read_csv("https://example.de/covid.csv")
data %>%
# group only by county
group_by(IdCounty, NameCounty) %>%
summarise(FreqCases = sum(FreqCases))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | danlooo |
