Skip to content

Instantly share code, notes, and snippets.

@jb0hn
Last active July 2, 2020 12:09
Show Gist options
  • Save jb0hn/90bab75e975fb9d9ec1e7226b0a7834a to your computer and use it in GitHub Desktop.
Save jb0hn/90bab75e975fb9d9ec1e7226b0a7834a to your computer and use it in GitHub Desktop.
EU2019PL_election_research
library(ggplot2)
freq <- c(845656, 2113793, 2550637, 2639789, 1255613, 1220165, 1158729, 1704753)
freq <- data.frame(freq, row.names = c("<5k", "5-10k", "10-20k", "20-50k", "50-100k", "100-200k", "200-500k", ">500k"))
wies <- sum(freq$freq[1:4])
miasto <- sum(freq$freq[5:8])
freq_split <- c(wies, miasto)
data <- data.frame(freq_split)
data$typ <- c("do 50 tys.", "pow. 50 tys.")
options(scipen=10000)
ggplot(data, aes(data$typ, data$freq_split)) + geom_col() + xlab("Miejscowość") + ylab("frekwencja surowa")
freq$uprawnieni <- c(2091077, 5481958, 6026989, 5827265, 2704785, 2571167, 2194267, 2922008)
freq$percentage <- freq$freq / freq$uprawnieni * 100
data$percentage <- c(mean(freq$percentage[1:4]), mean(freq$percentage[5:8]))
ggplot(data, aes(data$typ, data$percentage)) + geom_col() + xlab("Miejscowość") + ylab("% osob glosujacych")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment