Created
May 25, 2017 09:53
-
-
Save psobczyk/f725c73ffa94f6e11ec1c20f5f782742 to your computer and use it in GitHub Desktop.
Dofinansowanie przypadające na województwa
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(dplyr) | |
library(ggplot2) | |
library(ggthemes) | |
top_percent <- granty %>% | |
group_by(rok) %>% | |
mutate(procent = kwota/sum(kwota)) %>% | |
arrange(desc(procent)) %>% | |
top_n(7, procent) %>% | |
mutate(pozycja = row_number(), | |
top = ifelse(pozycja <= 1, "2", ifelse(pozycja <= 3, "4", "8")), | |
top = factor(top, levels = c(2,4,8), | |
labels = c("Pierwsze", "od 2 do 3", "od 4 do 7"), ordered= TRUE)) %>% | |
group_by(rok, top) %>% | |
summarise(procent = sum(procent)) | |
ggplot(top_percent) + | |
geom_bar(aes(x = rok, y = procent, group = top, fill = top), | |
stat = "identity", position = "dodge") + | |
scale_y_continuous(name = "", labels = scales::percent) + | |
scale_fill_wsj() + | |
guides(fill = guide_legend(title = "województwa", title.position = "top", | |
override.aes = aes(size = 15), | |
reverse = FALSE, order = 1, ncol = 1)) + | |
theme_fivethirtyeight(base_size = 18) + | |
theme(panel.grid.major.x = element_blank(), | |
axis.text = element_text(color = "black"), | |
plot.title = element_text(size = 26, hjust = 1), | |
plot.subtitle = element_text(hjust = 1), | |
plot.background = element_rect(fill = 'white'), | |
panel.background = element_rect(fill = 'white'), | |
legend.background = element_rect(fill = 'white'), | |
legend.key = element_rect(fill = 'white'), | |
legend.position = "right") + | |
labs(title = "Procent łącznej kwoty grantów NCN", | |
subtitle = "Uzyskany przez województwa o największym dofinansowaniu") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment