지오메트리로 통계 처리

ggplot2로 하는 중급 데이터 시각화

Rick Scavetta

Founder, Scavetta Academy

ggplot2, 코스 2

  • 통계
  • 좌표계
  • 패싯
  • 데이터 시각화 모범 사례
ggplot2로 하는 중급 데이터 시각화

통계 레이어

  • 함수는 두 범주
    • geom 내부에서 호출
    • 독립 호출
  • stats_
ggplot2로 하는 중급 데이터 시각화

geom_ <-> stat_

p <- ggplot(iris, aes(x = Sepal.Width))
p + geom_histogram()

geomhistogram

ggplot2로 하는 중급 데이터 시각화

geom_ <-> stat_

p <- ggplot(iris, aes(x = Sepal.Width))
p + geom_histogram()
p + geom_bar()

geomhistogram

ggplot2로 하는 중급 데이터 시각화

geom_ <-> stat_

p <- ggplot(mtcars, aes(x = factor(cyl),  fill = factor(am))) 
p + geom_bar()
p + stat_count()

ggplot2로 하는 중급 데이터 시각화

geom_/stat_의 연결

stat_ geom_
stat_bin() geom_histogram(), geom_freqpoly()
stat_count() geom_bar()
ggplot2로 하는 중급 데이터 시각화

stat_smooth()

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 color = Species)) + 
  geom_point() +
  geom_smooth()
geom_smooth() using method = 'loess' and 
formula 'y ~ x'

ggplot2로 하는 중급 데이터 시각화

stat_smooth(se = FALSE)

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 color = Species)) + 
  geom_point() +
  geom_smooth(se = FALSE)
geom_smooth() using method = 'loess' and 
formula 'y ~ x'

ggplot2로 하는 중급 데이터 시각화

geom_smooth(span = 0.4)

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 color = Species)) + 
  geom_point() +
  geom_smooth(se = FALSE, span = 0.4)
geom_smooth() using method = 'loess' and 
formula 'y ~ x'

ggplot2로 하는 중급 데이터 시각화

geom_smooth(method = "lm")

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 color = Species)) + 
  geom_point() +
  geom_smooth(method = "lm", se = FALSE)

ggplot2로 하는 중급 데이터 시각화

geom_smooth(fullrange = TRUE)

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 color = Species)) + 
  geom_point() +
  geom_smooth(method = "lm", 
              fullrange = TRUE)

ggplot2로 하는 중급 데이터 시각화

geom_/stat_의 연결

stat_ geom_
stat_bin() geom_histogram(), geom_freqpoly()
stat_count() geom_bar()
stat_smooth() geom_smooth()
ggplot2로 하는 중급 데이터 시각화

기타 stat_ 함수

stat_ geom_
stat_boxplot() geom_boxplot()
ggplot2로 하는 중급 데이터 시각화

기타 stat_ 함수

stat_ geom_
stat_boxplot() geom_boxplot()
stat_bindot() geom_dotplot()
stat_bin2d() geom_bin2d()
stat_binhex() geom_hex()
ggplot2로 하는 중급 데이터 시각화

기타 stat_ 함수

stat_ geom_
stat_boxplot() geom_boxplot()
stat_bindot() geom_dotplot()
stat_bin2d() geom_bin2d()
stat_binhex() geom_hex()
stat_contour() geom_contour()
stat_quantile() geom_quantile()
stat_sum() geom_count()
ggplot2로 하는 중급 데이터 시각화

Ayo berlatih!

ggplot2로 하는 중급 데이터 시각화

Preparing Video For Download...