R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

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

#p.188 #1번

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번

mpg<-as.data.frame(ggplot2::mpg)
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()

#p.195 #1번.

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

#p.198 #1번

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

#한국어 데이터를 이용해 box plot 그리기

ggplot(data = mpg, aes(x = drv, y = hwy))+
  geom_boxplot()

read.table("C://Users//chosun//Desktop//이유진//korean_data (1).txt", fileEncoding="utf-8", head=T) ->korean
substr(korean$stimulus, 1,1) -> korean$gender
ggplot(data = korean, aes(x = gender, y = response)) +geom_boxplot()

#25% 값 : 1, median 값 : 4, 75% 값 : 7

Specify the correct file path