I have a dataframe (d1) with respondents answers to a series of questions (Q1-Q12), such that the questions are the column names and a respondents answers are 1 row across all the columns, the next respondents answers are row 2 across the columns. Another dataframe (d2) has a questions column with Q1-Q12 as the rows and a Correct_answers column with the correct answers to questions Q1-Q12
My question is how to compare the respondents answers in d1 with the correct answers in d2, changing the values in d1 to 1 if the respondent answered correctly and 0 if the respondent answered incorrectly.
Thanks