Find the columns in the numeric dataframe that represent responses to your quiz questions, and figure out which answer is correct by referencing the original quiz questions and the corresponding columns in the choice dataframe. In the example data, we look at the columns “Word1”, “Word2”, “Word3”, “Word4”, and “Word5”. Word1 should be 1, Word 2 should be 0, Word3 should be 1, Word4 should be 0 and Word5 should be 1.

numeric_data$Word1Accuracy <- ifelse(numeric_data$Word1 == 1,  1,0)
numeric_data$Word2Accuracy <- ifelse(numeric_data$Word2 == 0,  1,0)
numeric_data$Word3Accuracy <- ifelse(numeric_data$Word3 == 1,  1,0)
numeric_data$Word4Accuracy <- ifelse(numeric_data$Word4 == 0,  1,0)
numeric_data$Word5Accuracy <- ifelse(numeric_data$Word5 == 1,  1,0)

Code translation: we make a new column in the numeric dataframe called “Word1Accuracy”. For each row in this column, R checks the same row in the column named “Word1” is equal (==) to 1. If it is, the cell will contain a 1. If not, the cell will contain a 0. Then we do the same for “Word2”, “Word3”, “Word4”, and “Word5”.

Finally, we create a dataframe that contains all our accuracy evaluations for the memory test:

MemoryTest <- data.frame(numeric_data$Word1Accuracy, numeric_data$Word2Accuracy, 
                         numeric_data$Word3Accuracy, numeric_data$Word4Accuracy, 
                         numeric_data$Word5Accuracy)