I'd like to create a new column (Survey_score) to this dataset that calculates the average of Question (Q1-Q4) for each ID. I suspect I need to loop through each ID, but I'm sorta new to R. Any tips?
ID | Question | Answer |
---|---|---|
1 | Q1 | 2 |
1 | Q2 | 2 |
1 | Q3 | 1 |
1 | Q4 | 4 |
2 | Q1 | 1 |
2 | Q2 | 2 |
2 | Q3 | 4 |
2 | Q4 | 2 |