Assignment: Marking exams
For this assignment, create a file called YOURNAME_assignment_01.R, where you will put your solutions.
Description
Students have sat a multiple-choice exam. The exam had 100 questions, and each answer was one of a, b, c, d and e. We supplied a zip file data.zip which contains several files. You will need to first unzip this file. The file correct_answers.dat stores the correct answer for each question (in order), e.g. the fifth entry is the correct answer for question 5. The students had to answer 30 questions from the 100 available questions (each student had a different set of questions to answer) and their answers are stored in files student_ID.tsv. The first column of this file contains the question that is being answered and the second column, their answer.
Your task is to write a script that will mark each student's performance, and produce a data.frame which stores the results.
a) Read the correct answers and store it to a vector called correct_answers. What is the correct answer of question 54?
b) Create a vector with all filenames containing student's answers. The files containing student's answers are called student_ID.tsv.
c) Extract students IDs from the names of the files.
Hint: return a vector of integer numbers with the corresponding ID for each filename.
d) Write a function called markStudent to read a student's answers from the file and return the number of correct answers. How many answers did student 4 get?
Hint: The function should take as arguments the filename with the answers and a vector with the correct answers for all questions.
e) Compute the number of correct answers for each student. How many students got at least 20 correct answers.
f) Compute a mark for each student and store the marks into a vector called marks. Note that a mark is an integer between 0 and 100.
Hint: Each correct answer will weight 3.33 points. Round the mark to the closest integer.
g) Create a data.frame containing the following columns: studentID, filename, correct and mark. Order the data.frame based on student's id.
Export this data.frame to a file called students_marks_YOURNAME.tsv. Do not use quotation marks when writing the text and include in this file the colnames, but not the rownames.
Attachment:- Assignment Files.rar