条件が変わるたびに実験データをまとめたいと思います。
例えば:
> df=data.frame(tos=1:9, temp=rep(c(25,50,25), each=3), response=c(3.2,3.3,3.3, 6.5, 6.5, 6.5, 3.5,3.6,3.5))
> df
time temp response
1 1 25 3.2
2 2 25 3.3
3 3 25 3.3
4 4 50 6.5
5 5 50 6.5
6 6 50 6.5
7 7 25 3.5
8 8 25 3.6
9 9 25 3.5
これを次のように要約したいと思います。
temp response.mean
25 3.3
50 6.5
25 3.5
このようにddplyを使用する場合:
library(plyr)
ddply(df、c( "temp")、summary、reponse.mean = mean(response)
出力は次のとおりです。
temp response.mean
1 25 3.4
2 50 6.5
これを達成する方法はありますか?