tidyverse
作者:互联网
用到R语言自带的mtcars数据集,首先我们把它转化成tibble形式,然后存放在mtcars1中。准备代码如下:
library(tidyverse)
mtcars %>% as_tibble() -> mtcars
mtcars %>% group_by(cyl) %>% slice(1:3) %>% ungroup()
mtcars %>% group_by(cyl) %>% arrange(desc(hp)) %>% slice(1:3) %>% ungroup()
mtcars %>% group_by(cyl) %>% filter(hp > 150) %>% ungroup()
mtcars %>% group_by(cyl) %>% summarise(hp_max = max(hp)) %>% ungroup()
标签:group,tidyverse,mtcars,hp,ungroup,tibble,cyl 来源: https://www.cnblogs.com/xiaojikuaipao/p/15706896.html