Hello, new user here, hope I'm not breaking the protocol too much!
I am working on a data set of some ~15 variables, of which 10 I am analyzing and the rest are just to characterize the study sample. The range of the actual values of all variables is known. The good, and bad thing about this data is that there are many different numeric values to differentiate reasons why some data is missing, i.e. value 44 for a variable with a range of 0-30 to indicate a specific reason why it is missing, 55 for another reason etc. Missing data for some variables is coded as a negative value, which makes sense as all of the actual values are positive or zero.
Now, the problem is that I can't simply recode the 44's and 55's as NA for the entire data, as I'll have to report the age of the participants, which covers these values as well, and there are some other cases too where a NA value in one variable is a valid value for another. How should I proceed with the data set? Divide it into two, so there's the data for analysis, and data for study characteristics? How should I do the recoding to NA's as efficiently as possible in this situation, where some values designated to be NA's are straight forward (since no actual value should be < 0), and some overlap with values that should not be NA's. With some googling I was lead to understand that dplyr maybe could handle something like this, but I am not sure how to make it work for several variables with different conditions for being designated as NA. Is there some function that I can use to regard everything outside a specific range as NA, i.e. smaller than 0 and higher than 900?
To reiterate, I'm looking for some kind of solution in the form of: recode variables a through d values smaller than zero and higher than x as NA;
recode variables e through g values smaller than zero and higher than Y as NA; etc.
Thanks in advance!