在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
R语言中aggregate函数 1、测试数据1 name <- LETTERS[1:8]
gender <- c("M","F","F","M","F","M","M","F")
age <- c(30,20,40,40,30,20,30,20)
height <- c(100,200,300,200,400,500,100,600)
a <- data.frame(name,gender,age,height)
a
2、测试2 a
b <- aggregate(a[,3:4], by=list(gender=gender), FUN=mean)
b
3、测试3 c <- aggregate(a[,3:4], by=list(gender=gender), FUN=sum)
c
4、测试4 a
d <- aggregate(a[,4], by=list(age=age),FUN=mean)
d
5、测试5 a
e <- aggregate(a[,4],by=list(gender=gender,age=age), FUN=mean)
e
f <- aggregate(a[,4],by=list(gender=gender,age=age), FUN=sum)
f
|
请发表评论