Answer.Key <- c(3, 5, 1, 3, 4, 4, 4, 4, 1, 2, 1, 2, 4, 2, 2, 2, 3, 4, 1, 4, 4, 4, 4, 2, 5, 2, 2, 2, 2, 4, 2, 1, 3, 1, 3, 4, 4, 2, 4, 4, 3, 2, 3, 3, 2, 4, 1)
# A tibble: 341 x 47
Item1 Item2 Item3 Item4 Item5 Item6 Item7 Item8 Item9 Item10 Item11 Item12 Item13 Item14 Item15
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 2 5 1 1 2 4 4 2 5 2 1 2 1 1 2
2 1 5 1 3 4 4 4 4 1 2 1 2 2 2 2
3 2 5 1 3 4 4 4 2 1 2 1 2 3 2 2
4 3 5 1 3 4 4 4 4 1 2 1 2 4 2 1
5 1 5 4 3 4 4 4 4 1 2 4 2 2 2 1
6 3 5 1 3 4 4 4 4 4 2 1 2 4 2 2
7 3 5 1 3 4 4 4 4 4 2 1 2 2 2 2
8 3 5 1 3 2 4 4 4 1 2 1 2 1 1 2
9 3 5 1 3 4 4 4 4 1 2 1 2 2 2 1
10 3 5 1 3 4 4 4 4 1 2 1 2 4 2 2
# … with 331 more rows, and 32 more variables: Item16 <dbl>, Item17 <dbl>, Item18 <dbl>,
# Item19 <dbl>, Item20 <dbl>, Item21 <dbl>, Item22 <dbl>, Item23 <dbl>, Item24 <dbl>,
# Item25 <dbl>, Item26 <dbl>, Item27 <dbl>, Item28 <dbl>, Item29 <dbl>, Item30 <dbl>,
# Item31 <dbl>, Item32 <dbl>, Item33 <dbl>, Item34 <dbl>, Item35 <dbl>, Item36 <dbl>,
# Item37 <dbl>, Item38 <dbl>, Item39 <dbl>, Item40 <dbl>, Item41 <dbl>, Item42 <dbl>,
# Item43 <dbl>, Item44 <dbl>, Item45 <dbl>, Item46 <dbl>, Item47 <dbl>
I have the answers to a multiple choice test. 341 participants answered 47 questions. I have a key to this test as well. I understand how to use a for loop to change correct answers in one column at a time to 0, so I can just count how many zeros there are in a row and that is that participant's score. Only issue is there are 47 columns and each column has a different correct answer.
How can I use my answer key and assign each value in the answer key to its specific column? This would make the process much more efficient than writing 47 for loops for each column.
Thanks for any help.