I'm working on a dataframe in RStudio and want to understand if there is a correlation between physical exercise and a person's general physical health. For this, I'm using three variables:
exerof1: This variable indicates how many times the respondent has done some physical activity in the last 30 days.
exerany2: This question asks respondents if they have had any physical activity in the last thirty days.
genhlth: it is an ordinal categorical variable that asks the respondents about their own general health, and they can choose the following answers: excellent, very good, good, bad, very bad
I have already made some adjustments to the "exeroft" variable, only 30% of the responses of this variable are "NAs" and most of these NAs occur because people answered "No" in the variable "exerany2".
In this sense, my goal is to identify which people said no to the "exerany" question and are listed as "NAs" in the "exerof1" variable, and from that I want to transform that data to "0".
I do not know if this is the best way to do this because I'm still a beginner. I tried to use the ifelse function, but it's giving me a problem because I can not mount the equation without affecting the other part of the variable, which is the number of times people exercised in the last month.
ps: Thank you for letting me know that you were in Portuguese Articuno!
I thank you in advance.
Sincerely,