혼자서 해보기

mpg 데이터와 midwest 데이터를 이용해서 분석 문제를 해결해 보세요.

library(ggplot2)
library(dplyr)
## 
## 다음의 패키지를 부착합니다: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
ggplot(data = mpg, aes(x = cty, y = hwy)) + geom_point()

ggplot(data = midwest, aes(x = poptotal, y = popasian)) + geom_point() + xlim(0, 500000) + ylim(0, 10000)
## Warning: Removed 15 rows containing missing values (`geom_point()`).

mpg 데이터를 이용해서 분석 문제를 해결해 보세요.

install.packages("dplyr")
## Warning: 패키지 'dplyr'가 사용중이므로 설치되지 않을 것입니다
df <- mpg %>%  filter(class == "suv") %>%  group_by(manufacturer) %>% summarise(mean_cty = mean(cty)) %>% arrange(desc(mean_cty)) %>% head(5)
ggplot(data = df, aes(x = reorder(manufacturer, -mean_cty), y = mean_cty)) + geom_col()

ggplot(data = mpg, aes(x = class)) + geom_bar()

class_mpg <- mpg %>% filter(class %in% c("compact", "subcompact", "suv"))
ggplot(data = class_mpg, aes(x = class, y = cty)) + geom_boxplot()

ggplot(data = economics, aes(x = date, y = psavert)) + geom_line()

class_mpg <- mpg %>% filter(class %in% c("compact", "subcompact", "suv"))
ggplot(data = class_mpg, aes(x = class, y = cty)) + geom_boxplot()

한국어 데이터를 이용해 box plot 그리기. x 축을 gender y 축을 response로 하는 그림을 그리세요. 그 후 boxplot에서 나타내는 25% 값, median, 75% 값을 각각 찾아 쓰세요.

library(readxl)
korean <- read_excel("C:\\Users\\chosun\\Downloads\\korean_data_.xls")
ggplot(data = korean, aes(x = gender, y = response)) + geom_boxplot()