Last active
December 29, 2016 03:48
-
-
Save so-c/8007552 to your computer and use it in GitHub Desktop.
読んだ本の年ごとの積み上げ棒グラフ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("tidyverse") | |
raw.entries <- data.frame(年=factor(c(2012, 2013, 2014, 2015, 2016)), | |
小説=c(69, 65, 71, 65, 90), | |
読書=c(34, 48, 24, 30, 21), | |
新書=c(3, 2, 9, 5, 4), | |
漫画=c(17, 44, 67, 80, 97)) | |
entries <- raw.entries %>% gather(ラベル, 冊数, -年) | |
g <- ggplot(entries, aes(x=年, y=冊数, fill=ラベル)) | |
p <- g + geom_bar(stat="identity") | |
p <- p + ggtitle("読んだ本") | |
plot(p) | |
ggsave(file="books2015.png", plot=p, width=8.0, height=6.4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment