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값이 음수이면 막대 위에 레이블이 생김