I have a data set of different cities and the different sports teams they have:
**City** **Basketball** **Soccer** **Tennis** **Football**
AA Titans Astros Royals Eagles
AA Crimson NA Falcons Packers
AA NA Phoenix Tigers NA
AA Goblins NA Lions NA
BB NA NA NA NA
BB Bears Rockets Broncos NA
CC Pelicans Wildfires Panthers NA
CC NA Bobcats Blizzard NA
CC NA NA Tornadoes NA
CC NA NA Hurricanes NA
I want to group the data by city and find the total number of NAs for each columnn for each city. How would I go about doing this? I've tried this after doing some research
aggregate(df[,2:4], by=list(df$City), colSums(is.na(df)))
but it doesn't work...