Created
January 16, 2012 06:12
-
-
Save fredbenenson/1619331 to your computer and use it in GitHub Desktop.
Graphing SOPA Shirt Distributions
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
#Sopa data munging: | |
sopa.d <- read.csv("~/Downloads/Kickstarter Backer Report - $15 reward - Jan 15 6pm.csv") | |
sopa.i <- read.csv("~/Downloads/Kickstarter Backer Report - $30 reward - Jan 15 6pm.csv") | |
#International survey didn't have the pickup question so fake a column: | |
sopa.i$Choices.2 <- sopa.i$Choices.1 | |
sopa.i$Choices.1 <- "No" | |
sopa <- rbind(sopa.d, sopa.i) | |
# Rename Levels: | |
levels(sopa$Choices.2) <- c(NA, "Grey", "White", "White") | |
#Rename columns: | |
colnames(sopa) <- c(head(colnames(sopa),-3), "shirt_size", "pickup", "color") | |
#Reorder sizes levels: | |
sopa$shirt_size <- factor(sopa$shirt_size, levels = c("", "S", "M", "L", "XL", "XXL")) | |
#Data.frame should look like this: | |
# City State Postal.Code Country shirt_size pickup color i8n | |
#1 Brooklyn NY 11201 USA XL Yes Grey FALSE | |
#2 xxx xxx xx USA M Yes White FALSE | |
#3 mountain view ca 94117 USA M No Grey FALSE | |
#4 New York NY 10002-2412 USA XL Yes Grey FALSE | |
#5 Brooklyn NY 11215 USA L Yes Grey FALSE | |
#6 New york New York 10013 USA XL Yes Grey FALSE | |
qplot(data = droplevels(subset(sopa, shirt_size != "")), x = shirt_size, fill = color, color = I("black"), position = "dodge") + | |
scale_fill_manual("Color", breaks = c("Grey", "White"), values = c("grey", "White")) + | |
scale_x_discrete("Shirt Size", breaks = c("", "L", "M", "S", "XL", "XXL"), labels = c("No response", "L", "M", "S", "XL", "XXL")) + | |
scale_y_continuous("Backers") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment