Skip to content
Prev 257907 / 398502 Next

average among one factor in a nested dataframe

Never mind, I find a generic solution:

require(reshape)
melted<-melt(dataframe, id=c("id","f1","f2"))
averaged=cast(melted,id+f1~variable,mean)

which collapses away "f2", and it's easy to generalize this to collapse
any factors.

Thanks anyway
Gordon
On 4/25/11 6:14 AM, Kenneth Roy Cabrera Torres wrote: