I am currently working on my masters thesis and part of my data analysis is in R. I am completely new to it and so am learning as I go along.
The experiments we are running consist of individuals playing a token allocation game, over a series of rounds.
I need to change the current csv file in R so that each individual appears in one row, with ingroup, outgroup and self giving summed over the 40 rounds they played.
Currently, the data frame is as follows:
id roundno tokenstoingroup tokenstooutgroup tokenstoself
0001 1 1 0 0
0001 2 0 1 0
0002 1 0 0 1
etc...
There are many participants (over a thousand), and every round's allocation for each participant is entered.
My question is:
How do I sum this up so that the data frame looks more like this??
id totalrounds tokenstoingroup tokenstooutgroup tokenstoself
0001 40 25 13 2
002 40 13 13 14
etc...
As I have said, I am totally new to this. I have tried to look online for aggregating and summing things up, but I have idea where to start with something a bit more complex like this.