I am trying to to group_by program names and count the total column amounts per program. There are NA's in the mix.
Taking a data frame like this: dataframe
and getting something like in return returned data
The following code only counts all non NA observations. It doesn't actually add up the numbers. Do I need to do some sort of ifelse here? I also wonder if the !is.na causes it to count all non NA observations, however, if I remove it, I get all NA's as my totals.
df %>%
group_by(ProgramName) %>%
summarise(ED = sum(!is.na(HighSchool)), EMP = sum(!is.na(Employment)))
alternatively, is there is a way to group by program name and count the observations ONLY if they had a 1 in either column, not to tally up the total? That is closer to what I want anyway. Any support would be appreciated.
To answer both questions: