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()

 

 

 

上一篇:实验五 模板类与多态


下一篇:实验5