I have a data set like so
Date Facility Meas_1 Meas_2 Meas_3
1/1/2021 C 0 0 0
1/1/2021 Ge 0 1 0
1/1/2021 A 0 0 1
1/1/2021 A 0 0 0
1/1/2021 P 1 0 0
1/1/2021 C 0 0 0
1/1/2021 Ge 0 0 0
1/1/2021 P 0 0 0
1/1/2021 R 1 1 0
1/1/2021 C 0 0 0
1/2/2021 Ga 0 1 0
1/2/2021 C 0 0 0
1/2/2021 C 0 1 0
1/2/2021 A 1 0 0
1/2/2021 E 0 0 0
And need to find the sum of Meas_1, Meas_2, and Meas_3 based on the Value of Facility and the date. Facility is a Factor and the measures are binary, 1 being true 0 being false. I'm trying to get a count of each at each facility.
I've tried aggregate with no luck, thank you!
df %>% group_by(Date, Facility) %>% summarise(across(starts_with("Meas"), sum), .groups = "drop")?aggregate(.~Date + Facility, df, mean)is the way to useaggregate