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
## harald, 2012-11-11 | |
# this script downloads all exit polls for the U.S. presidential | |
# election on 2012-11-06 from CNN and saves the resulting | |
# data.frame to file | |
# for later puropses it can be loaded by | |
# load(file="PresExitPolls2012.Rdata") | |
library(XML) | |
library(plyr) | |
source("getStateData.R") |
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
unique(EP$QNo[EP$question=="Vote by Age"]) | |
# 4 category breakdown | |
head(EP[EP$QNo==2, ]) | |
# 6 category breakdown | |
head(EP[EP$QNo==3, ]) |
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
# numbers from http://news.cnet.com/8301-13578_3-57546778-38/among-the-top-election-quants-nate-silver-reigns-supreme/ | |
nate <- c(50.8, 48.3) | |
tpm <- c(48.8, 48.1) | |
rcp <- c(48.8, 48.1) | |
huff <- c(48.1, 46.7) | |
png('crosshairs2.png') | |
crosshairs(centre = centre, # the actual popular vote | |
pts = pts, # the predistions | |
no.rings = 4, # four rings seem about right here ("4 more years") | |
title = "Pollsters on target?", |
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
## harald, 2012-11-08 | |
# make crosshairs plot for pollster precision | |
# this version prepared for the blogpost | |
# on http://adistantobserver.blogspot.de/2012/11/pebos-post-election-burn-out-syndrome.html | |
# first a helper function for downloading the necessary data | |
getTablesFromURL <- function (URI, index = integer(), header = FALSE) { | |
require(RCurl) | |
require(XML) | |
result <- getURLContent(URI, useragent = "RCurl") |