p.188 혼자서해보기 1번

library(ggplot2)
ggplot(data = mpg, aes(x = cty, y = hwy))+geom_point()

2번

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

p.193 혼자서 해보기1번

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
mpg %>% filter(class == "suv") %>% group_by(manufacturer) %>% summarise(mean_cty = mean(cty)) %>% arrange(desc(mean_cty)) %>% head(5) ->df
ggplot(data = df, aes(x = reorder(manufacturer, -mean_cty),y=mean_cty))+geom_col()

2번

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

p.195 1

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

p.198 1

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

2.한국어 데이터를 이용해 box plot 그리기. x 축을 gender y 축을 response로 하는 그림을 그리세요.

library(readxl)
read_excel("/Users/andahui/Library/Containers/com.microsoft.Excel/Data/Downloads/korean_data_ANSI.xls") ->korean
library(ggplot2)
ggplot(data = korean, aes(x= gender, y= response)) + geom_boxplot()

q1 <- quantile(korean$response, probs = 0.25)
q2 <- quantile(korean$response, probs = 0.5)
q3 <- quantile(korean$response, probs = 0.75)
q1
## 25% 
##   1
q2
## 50% 
##   4
q3
## 75% 
##   7