Calculate the mean by group

后端 未结 5 1012
没有蜡笔的小新
没有蜡笔的小新 2020-11-21 04:42

I have a large data frame that looks similar to this:

df <- data.frame(dive = factor(sample(c("dive1","dive2"), 10, replace=TRUE)),
            


        
5条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-21 05:45

    aggregate(speed~dive,data=df,FUN=mean)
       dive     speed
    1 dive1 0.7059729
    2 dive2 0.5473777
    

提交回复
热议问题