I have a data frame and I would like to group by the column "State" and "Date" and then summarize the values of the other columns something like this.
df
State Female Male Date
------------------------------
Texas 2 2 01/01/04
Texas 3 1 01/01/04
Texas 5 4 02/01/04
Cali 1 1 05/06/05
Cali 2 1 05/06/05
Cali 3 1 10/06/05
Cali 1 2 10/06/05
NY 10 5 11/06/05
NY 11 6 12/06/05
Outcome expected
df
State Female Male Date
------------------------------
Texas 5 3 01/01/04
Texas 5 4 02/01/04
Cali 3 2 05/06/05
Cali 4 3 10/06/05
NY 10 5 11/06/05
NY 11 6 12/06/05
I tried with group by and summarize but I donĀ“t exactly how con I do the same for 2 columns
My try
df <- df_homicides %>%
group_by(state) %>%
summarise(Female = sum(Female))
``
Thanks for your help!