Last active
August 29, 2015 14:04
-
-
Save felixhaass/4e5c54f32c0e244c3be6 to your computer and use it in GitHub Desktop.
Breakdown of ECPR SSMT14 Nationalities (Edit: In fact, this rather counts the countries of participants' institution affiliation.)
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(XML) | |
library(ggplot2) | |
# This is a snapshot from the ECPR Moodle's Participant, copy & pasted in HTML | |
# I've deleted names for privacy reasons | |
ecpr <- readLines("https://www.dropbox.com/sh/9swobnm3s1lth00/AABHowrIWds1G4pfybDdU0q8a/Participants.htm?dl=1") | |
# convert to data.frame | |
ecpr_df <- as.data.frame(readHTMLTable(ecpr, header = FALSE)) | |
# cosmetics & percentages | |
ecpr_part <- data.frame(country = names(sort(table(ecpr_df[, 2]), decreasing = TRUE)), | |
count = sort(table(ecpr_df[, 2]), decreasing = TRUE)) | |
ecpr_part$country2 <- factor(ecpr_part$country, levels = ecpr_part[order(ecpr_part$count), "country"]) | |
ecpr_part$percent <- as.numeric(round(ecpr_part$count / sum(ecpr_part$count) * 100, 1)) | |
# plot all the things | |
plot <- ggplot(ecpr_part, aes (y = count)) | |
plot <- plot + geom_bar(aes(x = country2), stat = "identity") | |
plot <- plot + theme_bw() + xlab("") + ggtitle("Breakdown of ECPR SSMT14 Nationalities\n") + ylab("\n\nCounts; Source: moodle.ecpr.eu") | |
plot <- plot + coord_flip() | |
plot <- plot + geom_text(aes(x = country2, label=count),hjust= -.4, size = 3) | |
ggsave(plot, filename = "SSMTparticpants.png", dpi = 300) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment