发文章
发文工具
撰写
网文摘手
文档
视频
思维导图
随笔
相册
原创同步助手
其他工具
图片转文字
文件清理
AI助手
留言交流
aggregate(mtcars, by=list(cyl=mtcars$cyl), FUN=mean) aggregate(mtcars, by=list(cyl),mean) aggregate(.~cyl,mtcars, mean)
都是按照cyl(气缸数)对车进行分类(比如2缸4缸),每一类分别求其他参数(表里总共11个指标)平均数(比如2缸的车还有不同的里程数等)。
来自: 世上无难事bio > 《R语言》
0条评论
发表
请遵守用户 评论公约
神器purrr包是Hadley Wickham大神编写的高级函数编程语言包
library("purrr") #加载包data(mtcars) #使用数据集mtcarshead(mtcars) #查看mtcars数据的前五行dim(mtcars) #...
R语言 | 第5期. 你知道如何快速筛选你的变量和观测样本吗?
R语言 | 第5期. 你知道如何快速筛选你的变量和观测样本吗?公式:data %>% filter()举例:筛选mtcars数据中cyl等于4且disp小于平均数...
自学R语言(十五)-aggregate包的学习
自学R语言(十五)-aggregate包的学习caolong2019年4月14日aggregate函数应该是数据处理中常用到的函数,简单说有点类似sql语言中的group by,可以按照要求把数据打组聚合,然后对聚合以后的数据进行加...
R语言中aggregate函数
cdata.means <- aggregate(data[c("before","after","change")], by = data[c("sex","condition")], FUN=mean, na.rm=TRUE) cdata.means #> ...
管道函数以及其变形
The “exposition” pipe operator, %$% exposes the names within the left-hand side object to the right-hand side expression. Essentially, it is a short-hand for using the with functions (a...
5 分钟解读 Python 中的链式调用
cyl4 <- mtcars[which(mtcars$cyl==4), ]cyl6 <- mtcars[which(mtcars$cyl==6), ]cyl8 <- mtcars[which(mtcars$cyl==8), ]这里...
R语言dplyr包:高效数据处理函数(filter、group
R语言dplyr包:高效数据处理函数(filter、groupR语言dplyr包的数据整理、分析函数用法文章连载NO.01.本篇涉及到的函数为filter、filter_all()、filter_if()、filter_at()、mutate、group_by、select、...
“我爱你”44种语言的写法
“我爱你”44种语言的写法。
私人订制-R(function)
`mycal<-function(x){ mean<-mean(x) sd<-sd(x) result <- list(mean=mean,sd=sd) return(result)}x<-c(1,2,3,80)mycal(x)mysave<-function(earn,spend,lost){ save<- earn-spen...
微信扫码,在手机上查看选中内容