First time asking a question here and I'm new to R. I'm essentially working with a data frame that looks something like this (the row is longer than this, but it's to get the idea):
Category | Site |
---|---|
IV | NA |
I | Hip |
III | NA |
IVB | Leg |
IVA | NA |
II | Arm |
I want to remove the whole line if the row has an NA in the site AND is category IV, IVA, or IVB. I don't want to remove all of the rows with NA in Site.
This is what I've tried, but I can't seem to get it to work properly:
%>% filter(Category !=c("IV", "IVA", "IVB") & !is.na(Site))
I get this message:
Warning message: In Category != c("IV", "IVA", "IVB") : longer object length is not a multiple of shorter object length
And the resulting dataframe has removed all the rows with NA in site. I feel like I'm missing something very simple, but I can't seem to make it do what I want haha. Any help would be greatly appreciated!