I have a dataset I am taking from a public website using their R package and I have the full list. I am interested in a particular region of England, which is covered in the field ParentName. So, this below works:
mydata <- df[df$ParentName %in% c("South East region"),]
However, if I want to compare this to England overall, it does not have a value in ParentName, so I am looking to essentially filter on where ParentName is NULL/blank OR is the string value "South East region"
How might I go about that? I am extremely new to R and have had no training, so it is probably something very simple, but I can only seem to find guides on how to get rid of blanks! Thanks all.
I have tried using || but I don't think this works, or I am doing it wrong.
CodePudding user response:
If I understood correctly, this will work:
mydata <-
df[(df$ParentName == "South East region")|(df$ParentName == "")|(is.na(df$ParentName)),]
I recommend that you look at the dplyr
package later, it will make data manipulation easier.