rm(list=ls())

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)

data("iris")

table(is.na(iris))
## 
## FALSE 
##   750
glimpse(iris)
## Rows: 150
## Columns: 5
## $ Sepal.Length <dbl> 5.1, 4.9, 4.7, 4.6, 5.0, 5.4, 4.6, 5.0, 4.4, 4.9, 5.4, 4.…
## $ Sepal.Width  <dbl> 3.5, 3.0, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, 3.1, 3.7, 3.…
## $ Petal.Length <dbl> 1.4, 1.4, 1.3, 1.5, 1.4, 1.7, 1.4, 1.5, 1.4, 1.5, 1.5, 1.…
## $ Petal.Width  <dbl> 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.…
## $ Species      <fct> setosa, setosa, setosa, setosa, setosa, setosa, setosa, s…
iris %>% 
  select(Sepal.Width) %>% 
  ggplot(mapping = aes(x = Sepal.Width))+
  stat_density(alpha = 0.7,
               fill = 'steelblue',
               color = 'blue')+
  labs(title = 'Distribution:Sepal.Width')

iris %>% 
  select(Sepal.Length) %>% 
  ggplot(mapping = aes(x = Sepal.Length))+
  stat_density(alpha = 0.7,
               fill = 'steelblue',
               color = 'blue')+
  labs(title = 'Distribution:Sepal.Length')

iris %>% 
  select(Petal.Width) %>% 
  ggplot(mapping = aes(x = Petal.Width))+
  stat_density(alpha = 0.7,
               fill = 'steelblue',
               color = 'blue')+
  labs(title = 'Distribution:Petal.Width')

iris %>% 
  select(Petal.Length) %>% 
  ggplot(mapping = aes(x = Petal.Length))+
  stat_density(alpha = 0.7,
               fill = 'steelblue',
               color = 'blue')+
  labs(title = 'Distribution:Petal.Length')

AA <-iris %>% 
  ggplot(mapping = aes(x = Sepal.Length, y = Sepal.Width))+
  geom_point(aes(color = Species))+
  geom_smooth(method = 'lm')+
  scale_color_brewer(palette = 'Set1')

AA
## `geom_smooth()` using formula 'y ~ x'

BB <- iris %>% 
  ggplot(mapping = aes(x = Petal.Length, y = Sepal.Width))+
  geom_point(aes(color = Species))+
  geom_smooth(method = 'lm')+
  scale_color_brewer(palette = 'Set1')

BB
## `geom_smooth()` using formula 'y ~ x'

CC <- iris %>% 
  ggplot(mapping = aes(x = Petal.Width, y = Sepal.Width))+
  geom_point(aes(color = Species))+
  geom_smooth(method = 'lm')+
  scale_color_brewer(palette = 'Set1')

CC
## `geom_smooth()` using formula 'y ~ x'