R

heatmap with tidyverse package

이부일 2018. 8. 3. 14:05

tidyverse 패키지를 이용하여 두 개의 질적 자료(범주형 자료)에 대한 heatmap를 다음과 같이 작성할 수 있다.


install.packages("tidyverse")

library(tidyverse)

diamonds %>% 
     dplyr::count(cut, color) %>% 
     ggplot2::ggplot(mapping = aes(x = cut, y = color)) +
     geom_tile(mapping = aes(fill = n))


자동 대체 텍스트를 사용할 수 없습니다.


[출처] R for Data Science, Hadley Wickham & Garrett Grolemund, O'REILLY, p100~101