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
get_country_data <- function(country_name) { | |
# this puts a plus instead of the space, which is how the URL behaves | |
country_name <- gsub(" ", "+", country_name) | |
#this fixes ivory coast | |
country_name <- gsub("`", "%60", country_name) | |
# first part of the url | |
first_part <- "http://adoption.state.gov/maps/statistics/map_files/statistics.php?special=NONE&year=ALL&country=" |
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
data <- read.csv("county-data.csv") | |
#adds a county column by splitting in front of the parenthesis | |
data$county <- sapply(strsplit(as.character(data$ACCOMACK.VA.), split="\\("), function(x) { x[1] }) | |
#adds a state column by splitting after the parenthesis | |
data$state <- sapply(strsplit(as.character(data$ACCOMACK.VA.), split="\\("), function(x) { x[2] }) | |
#resplit the state data to get rid of the parenthesis sign at the end | |
data$state <- sapply(strsplit(as.character(data$state), split="\\)"), function(x) { x[1] }) |
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
setwd("~/dataviz-fall-2013/breaking-exercise") | |
data <- read.csv("ssamatab2.csv") | |
// Creates and orders unemployment rates for 2013 -- Discovers highest and lowest locations are AZ and ND// | |
Year2013 <- subset(data, Year == "2013") | |
Year2013 <- Year2013[order(Year2013$Unemployment.Rate, decreasing=T),] | |
//Want to chart unemployment rates for only North Dakota between 2000 and 2013. This targets North Dakota specifically and puts it in order by year // | |
ND <- subset(data, Area == "Bismarck, ND MSA") | |
ND <- ND[order(ND$Year, decreasing=T),] |
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
var networks = ["Comedy Central","TNT", "C-SPAN", "The Weather Channel", "MSNBC", "Bravo", "TBS", "ESPN2"] | |
var labels = svg.selectAll(".g-labels") | |
.data(prices) | |
.enter().append("text") | |
.attr("x", function(d,i) { return 4*i}) | |
.attr("y", function(d) { return height - y(d.X2013) - 14 }) | |
.text(function(d) { return d.Network + " ($"+ d.X2013 +")"; }) |
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
var networks = ["Comedy Central","TNT", "C-SPAN"]; | |
//inside the bars data join, this code is helpful | |
.classed("g-minor-highlight", function(d) { return networks.indexOf(d.Network) >= 0; }); |