This file contains hidden or 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(readr) | |
| # read | |
| eva <- read_csv("Extra-vehicular_Activity__EVA__-_US_and_Russia.csv") | |
| # extract years from somewhat inconsisten Date variable | |
| eva$year <- stringi::stri_extract_last_regex(eva$Date, "\\d{4}") # get year | |
| eva$year <- as.numeric(eva$year) | |
| # prepare plot data |
This file contains hidden or 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(countrycode) | |
| WDI("BA", indicator = c("SP.POP.TOTL"), start = 1975, end = 2011) %>% | |
| select(year, SP.POP.TOTL) %>% | |
| plot(., xlab = "", ylab = "", | |
| main = "Population Development of Bosnia and Herzegovina") | |
| mtext("Source: World Bank", side = 1, line = 3, adj = 1, cex = .6) |
This file contains hidden or 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)) |
This file contains hidden or 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
| got <- readLines("GoT_screentime_full.txt", encoding="UTF-8") | |
| gotdf <- data.frame(name=vector(), | |
| minutes=vector(), | |
| seconds=vector(), | |
| seasons=vector(), | |
| episode_count=vector()) | |
| for(i in 1:length(got)) { | |
| char <- strsplit(got[i], split=" = |\\. |\\(|\\:|; |)") |
This file contains hidden or 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
| pko <- read.table("./data/Data.Full.csv", header=TRUE, sep=",") | |
| pkoAfricaTotal <- pko[pko$tcc.continent=="Africa", ] # subset all African TCCs | |
| contribSum <- rowsum(pkoAfricaTotal$total, | |
| pkoAfricaTotal$tcc) # sum all contributions | |
| topTCC <- contribSum[order(contribSum[,1], decreasing=TRUE), ] # order countries | |
| # convert to dataframe |
This file contains hidden or 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(rworldmap) | |
| library(classInt) | |
| library(Cairo) | |
| library(RColorBrewer) | |
| # note that the 'animation' package requires ImageMagick to convert .png | |
| # to GIF: http://www.imagemagick.org/script/binary-releases.php | |
| library(animation) | |
| ################ |
This file contains hidden or 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
| # install the following packages | |
| library(scales) | |
| library(ggplot2) | |
| library(reshape) | |
| library(Cairo) | |
| library(RColorBrewer) | |
| ################ | |
| # Prepare data # |
This file contains hidden or 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
| # install the following packages | |
| library(scales) | |
| library(ggplot2) | |
| library(reshape) | |
| library(Cairo) | |
| ################ | |
| # Prepare data # | |
| ################ |
This file contains hidden or 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(ggplot2) | |
| library(Cairo) | |
| library(scales) | |
| library(RCurl) | |
| library(rjson) | |
| ################################# | |
| # Data preparation from web API # | |
| ################################# |