This document was created in RStudio using the rmarkdown package. For practice, I’ve reused some of the plots created during week two for an assignment, along with the related code.

Figure 1: Code and Plot

hotdogs <-read.csv("http://datasets.flowingdata.com/hot-dog-contest-winners.csv", sep=",", header=TRUE)
fill_colors <- c()
for ( i in 1:length(hotdogs$New.record) ) {
if (hotdogs$New.record[i] == 1) {
fill_colors <- c(fill_colors, "#821122")
} else {
fill_colors <- c(fill_colors, "#cccccc")
}
}
barplot(hotdogs$Dogs.eaten, names.arg=hotdogs$Year, col=fill_colors, border=NA, space=0.3, xlab="Year", ylab="Hot dogs and buns (HDB) eaten", main="Nathan's Hot Dog Eating Contest Results, 1980-2010")

Figure 2: Code and Plot

hot_dog_places <- read.csv('http://datasets.flowingdata.com/hot-dog-places.csv', sep=",", header=TRUE)
names(hot_dog_places) <- c("2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010")
hot_dog_matrix <- as.matrix(hot_dog_places)
barplot(hot_dog_matrix, border=NA, space=0.25, ylim=c(0, 200), xlab="Year", ylab="Hot dogs and buns (HDB) eaten", main="Hot Dog Eating Contest Results, 2000-2010")

Figure 3: Code and Plot

subscribers <-
read.csv("http://datasets.flowingdata.com/flowingdata_subscribers.csv", sep=",", header=TRUE)
plot(subscribers$Subscribers, type="h", ylim=c(0, 30000), xlab="Day", ylab="Subscribers")
points(subscribers$Subscribers, pch=19, col="black")

Figure 4: Code and Plot

population <-
read.csv("http://datasets.flowingdata.com/world-population.csv", sep=",", header=TRUE)
plot(population$Year, population$Population, type="l", bty="n", ylim=c(0, 7000000000), xlab="Year", ylab="Population")

Figure 5: Code and Plot

postage <- read.csv("http://datasets.flowingdata.com/us-postage.csv", sep=",", header=TRUE)
plot(postage$Year, postage$Price, type="s", main="US Postage Rates for Letters, First Ounce, 1991-2010", xlab="Year", ylab="Postage Rate (Dollars)")

Figure 6: Code and Plot

unemployment <- read.csv("http://datasets.flowingdata.com/unemployment-rate-1948-2010.csv", sep=",")
scatter.smooth(x=1:length(unemployment$Value), y=unemployment$Value, ylim=c(0,11), degree=2, col="#CCCCCC", span=0.5)