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
# Load RCurl package | |
library(RCurl) | |
addresses <- read.csv("~/links.csv") # Create a .csv file with all of the links you want to crawl | |
for (i in addresses) full.text <- getURL(i) | |
text.sub <- gsub("<.+?>", "", full.text) # Removes HTML tags | |
text <- data.frame(text.sub) |
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
# Create Google Motion Chart from World Bank Finance Data | |
# Inspired by http://lamages.blogspot.com/2011/09/accessing-and-plotting-world-bank-data.html | |
# Written by Christopher Gandrud | |
# 15 October 2011 | |
library(WDI) | |
library(gregmisc) | |
library(googleVis) | |
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
################ | |
# Partisan Inflation Forecast Error Graph | |
# Christopher Gandrud | |
# Updated 22 December 2011 | |
################ | |
library(foreign) | |
library(ggplot2) | |
## Load data |
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
## Download websites | |
addresses <- read.csv("~/links.full.csv") | |
for (i in addresses){ | |
fed.text <- getURL(i) | |
} | |
fed.df <- as.data.frame(fed.text) |
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
####################### | |
## Open text files, parse individually and remove text of the the speeches | |
setwd("~/fed.text.indv/") | |
# Create list of text files to parse and extract speech text from | |
files <- list.files(path = "~/fed.text.indv/", pattern = "*.txt") | |
# Create object to record empty text files (likely empty due to error in the website download) | |
missing <- NULL |
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
## Save raw HTML to individual text files for a subset | |
# Create id numbers that matches the full list of URLS | |
# This included URLs numbered 490 to 625 | |
fed.subset.df$id <- c(490:625) | |
y <- 1:nrow(fed.subset.df) | |
## Save Subset of HTML files | |
for(i in y) { |
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
############################## | |
# Create a Google Line Graph to Compare the Difference between Japanese & US GDP Growth using Data | |
# from the World Bank | |
# Christopher Gandrud | |
# Updated 29 December 2011 | |
############################## | |
library(WDI) | |
library(gregmisc) | |
library(googleVis) |
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
######################## | |
# Map of incidences of legislative violence (1980-2011) | |
# Christopher Gandrud | |
# Updated 6 September 2013 | |
######################## | |
library(foreign) | |
library(googleVis) | |
library(gregmisc) | |
library(plyr) |
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
######## | |
# Fed Inflation Forecast Error Times Series Graph | |
# Christopher Gandrud | |
# Updated 7 January 2011 | |
######## | |
### Using data frame cpi.data | |
#### Clean up data and create forecast error variable | |
cpi.data$pres_party <- factor(cpi.data$pres_party, label = c("Dem", "Rep")) |
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
############ | |
# Gallagher Disproportionality Data Explore | |
# Christopher Gandrud | |
# 25 March 2012 | |
########### | |
library(foreign) | |
library(ggplot2) | |
library(googleVis) | |
library(gdata) |
OlderNewer