Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@felixhaass
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felixhaass/4e5c54f32c0e244c3be6 to your computer and use it in GitHub Desktop.
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.)
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