今天是学习小组的第6天,学习的主要内容是 R包dplyr 的常用函数
Stay hungry. Stay foolish
思维 导图
library(dplyr)
test <- iris[c(1:2,51:52,101:102),]
mutate(test, new = Sepal.Length * Sepal.Width)##1.mutate(),新增列
select(test,1)##按列号筛选
select(test, Petal.Length, Petal.Width)##(2)按列名筛选
filter(test, Species == "setosa")##3.filter()筛选行
arrange(test, Sepal.Length)#默认从小到大排序
summarise()##汇总
管道操作 %>% (cmd/ctr + shift + M)
count(test,Species)##count统计某列的unique值
inner_join(test1, test2, by = "x")##取交集
left_join(test1, test2, by = 'x')##左连
full_join( test1, test2, by = 'x')##全连
semi_join(x = test1, y = test2, by = 'x')##半连
bind_rows(test1, test2)##按行合并
bind_cols(test1, test2)##按列合并
written by lpdmed
2020-07-23