0

I have a data frame "data" that looks like this

sub  time  condition mean

1   40  1 3
1   80  1 2
1  120  1 3
1  160  1 9
1   40  2 12
1   80  2 12
1  120  2 1
1  160  2 23
2   40  1 1
2   80  1 6
2  120  1 23
2  160  1 2
2   40  2 6
2   80  2 3
2  120  2 6
2  160  2 9 

I want to get the mean of variable mean for each time point (time) splitted by condition. I tried it with ddply but I couln't work it out: x = ddply(data,.(condition,time), summarize, mean=mean(mean)). Or do I have to rehape the data first? It should look like this:

 time condition mean
  40 1 2
  80 1 1.5
  .
  .
  .

Thankful for any comments or help! Angelika

0 Answers0