Students are being tested on multiple choice questions (MCQ) by using Zoom polling. There are 40 students in the class, and there are 30 MCQs. I don't really know how the polling works, but the course professor told me that Zoom will produce 30 excel csv files - one for each MCQ. Each file will have the name of the student, their ID, and either 1 or 0 points for the MCQ answer.
My job is to find a way to take all these 30 csv files (which I have kept in a folder), and merge them to find the total score for each student. So, I should be able to tell "How much did Kate score out of 30?".
Each csv file (which will be named MCQ1, MCQ2, ...) will look something like this:
Name SID Score
Kate 534 1
Bret 411 0
Jade 325 1
I have to do this using R. This is what I need:
Name SID MCQ1 MCQ2 MCQ3 MCQ4 MCQ5 ... Total
Kate 534 1 1 0 1 0 ... (=sum)
Bret 411 0 0 0 1 1 ... (=sum)
Jade 325 1 0 1 1 0 ... (=sum)
What needs to happen is R needs to find the MCQ scores for each student using "Name" or "SID" and stack only the scores one after another.
I have looked at the following posts here in SO.
- Importing multiple Excel files with filenames in R
- How can I read multiple (excel) files into R? [duplicate]
- How to import multiple .csv files at once?
Here is what I have so far:
total_score <- list.files(pattern = "*.csv") %>% map_df(read_csv)
Name SID Score
Kate 534 1
Bret 411 0
Jade 325 1
Kate 534 1
Bret 411 0
Jade 325 0
Kate 534 0
Bret 411 0
Jade 325 1
Kate 534 1
Bret 411 1
Jade 325 1
Kate 534 0
Bret 411 1
Jade 325 0
How do I tell R not to repeat the first two columns, and to only take each "score" column from the files for each specific student and then put them as new columns named after the csv files? Can someone point me in the right direction?