I need to keep NAs in my variables.
I have a variable with names, some have upper and some mixed cases. I want to generate a variable which defines the following name with at least one lower cases = 1 name with only upper cases = 0 NA = (I want to keep it, because I need to make my regressions with non-response)
My code is the following, but I don't know how to implement the NA command.
df <- grepl("[a-z]", x$variable)
You could use
ifelseandis.nato check for NA first and only use the result ofgreplfor values other than NA: