-
막대의 높이를 알려주는 레이블 추가하기R 2017. 10. 27. 20:00
install.packages("ggplot2")
install.packages("dplyr")
library(ggplot2)
library(dplyr)# cut에 대한 빈도를 가지는 새로운 데이터 생성하기
cut.table - ggplot2::diamonds %>%
dplyr::group_by(cut) %>
dplyr::summarise(n = n())# 막대에 레이블 추가하기
ggplot2::ggplot(data = cut.table, aes(x = cut, y = n)) +
geom_bar(stat = "identity", fill = "purple") +
geom_text(aes(label = n), vjust = -0.3)# vjust값이 음수이면 막대 위에 레이블이 생김
'R' 카테고리의 다른 글
Structure of Graphic Device (0) 2017.11.05 R Graphics (0) 2017.11.05 ggplot2로 상자그림 작성하기 (0) 2017.10.27 ggplot2의 Layers (0) 2017.10.27 Marginal Histogram / Boxplot (0) 2017.10.22