thanks for the help in advance. I'm relatively new to R and I'm still learning how to properly use it for data analysis. I currently have my data set up like so:
A B C D E NEVER
NOT APPLICABLE NOT APPLICABLE NOT APPLICABLE NOT APPLICABLE NOT APPLICABLE yes
NOT APPLICABLE NOT APPLICABLE NOT APPLICABLE NOT APPLICABLE NOT APPLICABLE yes
NOT APPLICABLE NOT APPLICABLE NOT APPLICABLE NOT APPLICABLE NOT APPLICABLE yes
NA NA NA NA NA NA
NA NA NA NA NA NA
NA NA NA NA NA NA
NA NA NA NA NA NA
NOT APPLICABLE NOT APPLICABLE NOT APPLICABLE NOT APPLICABLE NOT APPLICABLE yes
NA NA NA NA NA NA
NA NA NA NA NA NA
yes yes yes yes NA NA
NA NA NA NA NA NA
NA no no NA NA NA
yes no no no no NA
yes NA NA NA NA NA
yes yes yes yes yes NA
NA NA NA NA NA NA
I'm trying to find a way to go through multiple columns to change them so that R will look through Row Y, Column A and see if there is a "YES", then if there is a YES to make a new column and input "YES" as the value for Row Y
This would one situation. In another situation, R would go to Row Y and then do the same function, but if it can't find a YES, it will then look for a "NO" and if there is a "NO" it will input "NO" into the newly created column
Finally, the last possibility would be that there is neither a "YES" nor a "NO" in which case I want R to put in "NA" into the newly created column
I would want this command to be executed to Row Y+1300 (the end of the dataset)
IMPORTANT: What also threw me off is that the last column makes it so that it asks the opposite question essentially, so I would want the "YES"s and "NO"s to be flipped to be the opposite (YES becomes NO, vice versa) prior to the R loop command
EDIT: I originally was going to use a for-loop but there are too many different combinations, so I was hoping to find a more effective way to streamline the commands
EDIT: each row represents a different participant so I want to see whether or not they answered "yes" for any of the columns A-E and "no" for NEVER AND if that's not the case then to see if they answered "no" for any of column A-E and "yes" for NEVER AND if that's not the case then they must have "NA" for all those 6 columns