1、

gender <- rep(c("male", "female"), 2)
age <- c(20, 30, 26, 32)
height <- c(170, 180, 175, 178)
dat <- data.frame(gender, age, height)
dat
aggregate(dat[,2:3], by=list(gender), FUN=mean)     ## 依据gender列整合,求2、3列整合后的平均值

R语言 <- aggregate r语言aggregate函数怎么求平均值_R语言 <- aggregate