I have a data frame with three columns. The first column involves the questions, the second column involves the answer types (passive, active, neither) and the third column involves the ID (e.g., 1,2,3...) of the participant. For each participant, there are 18 questions. I want to create a loop where for each participant I can count the number of active, passive, and neither responses. I tried to do with aggregate and group by function but it did not work. As my data is not numerical I could not find the appropriate function. How can I solve this? My data frame looks like this:
questions resp_type participant
question1 active 1
question2 passive 1
.
.
.
question18 neither 1
question1 passive 2
question2 active 2
question3 active 2
.
.
.