This is my first time on stack. I have tried searching for an answer but i can't seem to find anything relevant. I hope someone can help.
I have a dataframe here: each subject does 6 trials, there are 105 subjects.
I want to find the mean of 'skip' for 6 trials for each subj.
Please can someone give me a hint as to how to start.
> subj entropy n_gambles trial choice
1 0 high 2 0 skip
2 0 high 2 1 skip
3 0 high 2 2 skip
4 0 high 2 3 skip
5 0 high 2 4 skip
6 0 high 2 5 skip
7 1 high 32 0 buy
8 1 high 32 1 buy
9 1 high 32 2 buy
10 1 high 32 3 buy
11 1 high 32 4 buy
12 1 high 32 5 buy
You can use
ddply
from plyr package: (You mentioned that there will be six trials, so mean is computed by dividing 6 for number of observations with just choice=skip for each subject)Note: df is your data
If I have to guess, then you intend to get mean of
n_gambles
for each subject wherechoice==skip
, then this might work:EDIT: As I understand you want frequency of
skip
persubj
: Try this: