P188
1번.
library("ggplot2")
## Warning: 패키지 'ggplot2'는 R 버전 4.3.2에서 작성되었습니다
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()`).
P193
library("dplyr")
## Warning: 패키지 'dplyr'는 R 버전 4.3.2에서 작성되었습니다
##
## 다음의 패키지를 부착합니다: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
1번.
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()
2번.
ggplot(data=mpg, aes(x=class)) + geom_bar()
P195
1번.
ggplot(data=economics, aes(x=date, y=psavert)) + geom_line()
P198
1번.
mpg <- as.data.frame(mpg)
class_mpg <- mpg %>% filter(class %in% c("compact", "subcompact", "suv"))
ggplot(data=class_mpg, aes(x=class, y=cty)) + geom_boxplot()
read.table("korean_data.txt", header = T) -> korean
korean$gender <- substr(korean$stimulus, 1, 1)
library("ggplot2")
ggplot(data=korean, aes(x=gender, y=response)) + geom_boxplot()
F 25% 값 = response 5 75% 값 = response 7
M 25% 값 = response 1 75% 값 = response 2