0

I'm working in Rmarkdown.

I have 11 columns in a dataframe that all have correct and incorrect answers as strings. I would like to loop over the 11 columns and score correct answers as 1 and incorrect ones as 0. Then, I would like to have a new final column in the dataframe that shows the total number of correct answers.

I'm putting down an example of the correct answers I'm working with to help. #df$q1 Correct Answer: Washington #df$q2 Correct Answer: Salmon #df$q3 Correct Answer: Green

I was trying if else statements, and I couldn't get it to work! Any help would be appreciated!

0 Answers0