8.1 통계치 계산하기
먼저 Y축에 표시될 자동차 유형별 고속도로 연비의 평균을 구해 보겠습니다.
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.0.5
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v tidyr 1.1.3 v dplyr 1.0.5
## v readr 1.4.0 v stringr 1.4.0
## v purrr 0.3.4 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
## x dplyr::recode() masks car::recode()
## x dplyr::select() masks MASS::select()
## x purrr::some() masks car::some()
library(MASS)
<- Cars93 %>%
dd group_by(Type) %>%
summarise(MPG.mean = mean(MPG.highway))
dd
## # A tibble: 6 x 2
## Type MPG.mean
## <fct> <dbl>
## 1 Compact 29.9
## 2 Large 26.7
## 3 Midsize 26.7
## 4 Small 35.5
## 5 Sporty 28.8
## 6 Van 21.9