I'm new to programming here, so I apologize that this is a rudimentary question. I'm working in R.
My data set: in brief, I have a list of about 30 diseases (some include asthma, back pain, etc. which would not necessarily indicate disease but, rather, some sort of chronic condition). For each question, respondents answered "1" if they have the disease, "2" if not, and "88" if they didn't know their disease status.
I want to create a new variable, say, called "chronic", which captures all individuals that have either 1, 2, or 3+ chronic conditions. Of course, I could sit here and go through all the conditionals, but is there an efficient way to scan across each specific disease column, and if participants answered "1", create some sort of running sum such that the total in this new "chronic" variable indicates the number of chronic conditions they have?
Thanks in advance