This is a way to get the result you want (there are many ways)
library(dplyr)
# Made up data just to exemplify, you can replace this with your own data frame
sample_data <- data.frame(
response = c(0, 1, 0, 1),
correctResponse = c(1, 0, 0, 1)
)
# Relevant code
sample_data %>%
mutate(test = as.numeric(response == correctResponse))
#> response correctResponse test
#> 1 0 1 0
#> 2 1 0 0
#> 3 0 0 1
#> 4 1 1 1
Created on 2022-05-29 by the reprex package (v2.0.1)
Note: Next time please provide a proper REPRoducible EXample (reprex) illustrating your issue.