r - Grading students' exams -
i think there's single line of code grades students' responses, can't quite find it. here's example 3 questions , 2 students.
thanks in advance
#the correct answers key = t(c(1,2,3)) #the student responses responses = t(data.frame(c(1,2,3),c(1,3,3))) colnames(responses) =c('v1','v2','v3') rownames(responses) = c('student1', 'student2') #the desired graded matrix graded = t(data.frame(c(t,t,t),c(t,f,t))) dimnames(graded) = dimnames(responses) graded
i'd way: responses == key[col(responses)]
Comments
Post a Comment