I have kinda a dumb r question. I'm trying to aggregate the total number of events in the same week (Year_Week) by location (Field). The below screenshot of my table is similar to my csv file. I was already able to sum the Score by Field and Year_Week using the following code: aggregate(x = df$Score, by = list(df$Year_Week, df$Field), FUN = sum)
However, I'm not sure about how to sum the events by Year_Week and Field. For example, because 2 games occurred during the week of 2019-4 in Irvine, I'd like my output to show "2". Similarly, because three games occurred the week of 2019-2, I want my output to show "3". I'd like my output table to look something like this:
where sum_Game is the number of games that occurred in one location (Field) in a given Year_Week, and sum_Score is the sum of the scores of those games. Thanks in advance!