I have a dataframe. I'd like to find out which disease is not recorded in an area. So for example: Area A does not have Mumps
What I'd like to do is wherever an area doesn't have a disease, I'd like to record a zero in the n column.
I thought it might be something like
DATA$missing<-DATA%>% if (DISEASE %in% DISEASE){"no"}
But that doesn't work and I didn't really expect it to but did hope it would...
Here's my data, in this example I've removed Mumps from Area A by filtering the original test data frame. How can I work out that Mumps isn't in Area A in this new data set? And other combinations of DISEASE AND AREA which might be missing and then return a value of n = 0 in the count column? thanks.
library (tidyverse)
library (epitools)
# here's my made up data
DISEASE = c("Marco Polio","Marco Polio","Marco Polio","Marco Polio","Marco Polio",
"Mumps","Mumps","Mumps","Mumps","Mumps",
"Chicky Pox","Chicky Pox","Chicky Pox","Chicky Pox","Chicky Pox")
YEAR = c(2011, 2012, 2013, 2014, 2015,
2011, 2012, 2013, 2014, 2015,
2011, 2012, 2013, 2014, 2015)
VALUE = c(82,89,79,51,51,
79,91,69,89,78,
71,69,95,61,87)
AREA =c("A", "B","C")
DATA = data.frame(DISEASE, YEAR, VALUE,AREA)
DATA<-DATA%>%filter(DISEASE !="Mumps" | AREA !="A")
Edit: My expected outcome would be this
new_row<-c("Mumps","2015",0,"A")
DATA<-rbind(DATA,new_row)