Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dofinansowanie przypadające na województwa
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
You can’t perform that action at this time.