my df
is:
--id q1 q2 q3 q4 q5 q6 q7 1 112 b c d d c 2 222 e b c d c 3 342 d c c d c d 4 454 b d e c b 5 554 c d d 6 136 b d e d
i have solution:
solution= c(0, a, b, c,a, d, d, a)
i wanted know if there score
function use see how many right answers got compared solution.
we can try rowsums
after creating logical matrix
rowsums(df[-1] == solution[col(df[-1])]) #1 2 3 4 5 6 #4 4 3 3 4 3
data
solution <- c('a', 'b', 'c','a', 'd', 'd', 'a')
Comments
Post a Comment