Find the two columns in the choice dataframe that have the drag n drop responses, and have a list at hand of which words should be in each column. In this example, the words “happy”, “tree”, and “fun” are supposed to be in the colum “MemoryWords1”, so we check for them:

numeric_data$Happy <- ifelse(grepl("happy",choice_data$MemoryWords1),1,0)
numeric_data$Tree <- ifelse(grepl("tree",choice_data$MemoryWords1),1,0)
numeric_data$Fun <- ifelse(grepl("fun",choice_data$MemoryWords1),1,0)

Code translation: we make a new column in the numeric dataframe called “Happy”. For each row in this column, R checks the same row in the choice dataframe column named “MemoryWords1” for the string of letters “happy” (make sure you use the same capitalization that exists in the data!). If the string is there, the row in the new column will contain a 1 and if the string isn’t there, the cell will contain a 0. Then we do the same for the words “Tree” and “Fun”.

Then, do the same for the words that are supposed to be in the other column. In our example, the words “apple”, “good”, and “bottle” are supposed to be in the colum “MemoryWords2”, so we check for them:

numeric_data$Apple <- ifelse(grepl("apple",choice_data$MemoryWords2),1,0)
numeric_data$Good <- ifelse(grepl("good",choice_data$MemoryWords2),1,0)
numeric_data$Bottle <- ifelse(grepl("bottle",choice_data$MemoryWords2),1,0)

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

MemoryTest <- data.frame(numeric_data$Happy, numeric_data$Tree, numeric_data$Fun,
                         numeric_data$Apple, numeric_data$Good, numeric_data$Bottle)