I am trying to write a logical statement in R, but it is not working. I am trying to check if an argument(state) passed to function is a valid state or not. If not, I write a stop statement and throw error message.
If !(state %in% state.abb) {stop("Invalid State")}
OR
If (state !%in% state.abb) {stop("Invalid State")}
Basically, I want to use "Not in" function and using operator "!%in%" as "Not in". It is not supported.