I am not sure if this is possible. I want to be able to use summarise to count all the rows that have NA in all the columns besides the group_by. I am able to do it by putting all 5 conditions together where I have NO_OL_Percent =
then have to connect each column with &
. If you can do it in SQL I should think you could do it with dplyr or purrr but seems like noone on the internet has tried this.
Data must be downloaded here
Code is below. It works but is there really not a way to use an all function for last row of code? I need to be able to do a group_by first and I cannot use the filter_all in dplyr.
farmers_market = read.csv("Export.csv", stringsAsFactors = F, na.strings=c("NA","NaN", ""))
farmers_market %>%
select(c("Website", "Facebook", "Twitter", "Youtube", "OtherMedia", "State")) %>%
group_by(State) %>%
summarise(Num_Markets = n(),
FB_Percent = 100 - 100*sum(is.na(Facebook))/n(),
TW_Percent = 100 - 100*sum(is.na(Twitter))/n(),
#fb=sum(is.na(Facebook)),
OL_Percent = 100 - 100*sum(is.na(Facebook) & is.na(Twitter))/n(),
NO_OL_Percent = 100 - 100*sum(is.na(Facebook) & is.na(Twitter) & is.na(Website) & is.na(Youtube) & is.na(OtherMedia))/n()
)