# this file analyzes WBC data # Matthew Salganik # Started January 2, 2012 # This code is placed in the public domain under a CC0 license # It does not do much, but you can use it as you wish rm(list=ls()); # clear memory # read in data # you will need to make sure that R can find the data votes <- read.csv("data/export_wbc_votes.csv", header=TRUE, sep=",", dec="."); banners <- read.csv("data/export_wbc_banners.csv", header=TRUE, sep=",", dec="."); non.votes <- read.csv("data/export_wbc_non_votes.csv", header=TRUE, sep=",", dec="."); # clean dates votes[, "Created.at.POSIX"] <- as.POSIXct(as.character(votes[,"Created.at"]), tz="America/San_Francisco", format="%Y-%m-%dT%H:%M:%S+00:00"); banners[, "Created.at.POSIX"] <- as.POSIXct(as.character(banners[,"Created.at"]), tz="America/San_Francisco", format="%Y-%m-%dT%H:%M:%S+00:00"); non.votes[, "Created.at.POSIX"] <- as.POSIXct(as.character(non.votes[,"Created.at"]), tz="America/San_Francisco", format="%Y-%m-%dT%H:%M:%S+00:00"); # add new information banners[,"Completed.Contests"] <- banners[, "Wins"] + banners[, "Losses"]; # add data from http://meta.wikimedia.org/wiki/Fundraising_2011 banner.names <- c("jimmy.default.1", "sarah", "jimmy.default.2", "jimmy.ads.long", "jimmy.ads.short", "jimmy.default.3", "james", "susan"); column.names <- c("click_rate", "don_per_imp", "amt_per_impression", "avg_donation", "wbc_score"); results <- matrix(NA, nrow=length(banner.names), ncol=length(column.names), dimnames=list(d1=banner.names, d2=column.names)); ###################### # September 9: http://meta.wikimedia.org/wiki/Fundraising_2011#September_9.2C_2011_EN_Sarah_appeal_Test row.jimmy.default <- which(banners[,"Idea.Text"]=="0001-Please read:\nA personal appeal from\nWikipedia founder Jimmy Wales") row.sarah <- which(banners[,"Idea.Text"]=="0006-Please read:\nA personal appeal from\nan author of 159 Wikipedia articles"); results["jimmy.default.1", ] <- c(0.016985, 0.000216, 0.004590, 20.6, NA); results["jimmy.default.1", "wbc_score"] <- banners[row.jimmy.default, "Score"]; results["sarah", ] <- c(0.016640, 0.000119, 0.002210, 22.14, NA); results["sarah", "wbc_score"] <- banners[row.sarah, "Score"]; ###################### ###################### # October 28: http://meta.wikimedia.org/wiki/Fundraising_2011#Banner_Text_Test_October_28.2C_2011 row.jimmy.default <- which(banners[,"Idea.Text"]=="0001-Please read:\nA personal appeal from\nWikipedia founder Jimmy Wales") row.jimmy.ads.long <- which(banners[,"Idea.Text"]=="0001-Please read:\nAdvertising isn't evil\nbut it doesn't belong on Wikipedia") row.jimmy.ads.short <- which(banners[,"Idea.Text"]=="0001-Advertising isn't evil\nbut it doesn't belong on Wikipedia") results["jimmy.default.2", ] <- c(0.01106169, 0.000153, 0.0023443863, 15.314044, NA); results["jimmy.default.2", "wbc_score"] <- banners[row.jimmy.default, "Score"]; results["jimmy.ads.long", ] <- c(0.00997582, 0.000148, 0.0027328871, 18.503206, NA); results["jimmy.ads.long", "wbc_score"] <- banners[row.jimmy.ads.long, "Score"]; results["jimmy.ads.short", ] <- c(0.00789402, 0.000121, 0.0018008150, 14.861852, NA); results["jimmy.ads.short", "wbc_score"] <- banners[row.jimmy.ads.short, "Score"]; ####################### ###################### # October 28: http://meta.wikimedia.org/wiki/Fundraising_2011#New_Editor_Appeals_Testing_October_28.2C_2011 row.jimmy.default <- which(banners[,"Idea.Text"]=="0001-Please read:\nA personal appeal from\nWikipedia founder Jimmy Wales") row.susan <- which(banners[, "Idea.Text"]=="0005-Please read:\nA personal appeal from\nan author of 549 Wikipedia articles"); row.james <- which(banners[,"Idea.Text"]=="0002-Please read:\nA personal appeal from\nWikipedia editor Dr. James Heilman"); results["jimmy.default.3", ] <- c(0.01305388, 0.000143, 0.0029169563, 20.335882, NA); results["jimmy.default.3", "wbc_score"] <- banners[row.jimmy.default, "Score"]; results["susan", ] <- c(0.02151122, 0.000160, 0.0032785171, 20.544824, NA); results["susan", "wbc_score"] <- banners[row.susan, "Score"]; results["james", ] <- c(0.01162289, 0.000059, 0.0011238652, 18.988889, NA); results["james", "wbc_score"] <- banners[row.james, "Score"]; #################### # make graph pdf(file="out/all_banners.pdf") par(mar=c(5, 4, 7, 1)) plot(results[, "click_rate"], results[, "wbc_score"], xlab="Score", ylab="Click rate", xlim=c(30, 70), ylim=c(0.005, 0.025), type="n") # color scheme comes from http://colorbrewer2.org/ color.group.1 <- rgb(27, 158, 119, maxColorValue=255); color.group.2 <- rgb(217, 95, 2, maxColorValue=255); color.group.3 <- rgb(117, 112, 179, maxColorValue=255); cex.value <- 0.7; text(results["jimmy.ads.long", "wbc_score"], results["jimmy.ads.long", "click_rate"], labels="1", col=color.group.2); mtext(side=3, line=6, cex=cex.value, text="1: [Jimmy] Please read: Advertising isn't evil but it doesn't belong on Wikipedia") text(results["jimmy.ads.short", "wbc_score"], results["jimmy.ads.short", "click_rate"], labels="2", col=color.group.2); mtext(side=3, line=5, cex=cex.value, text="2: [Jimmy] Advertising isn't evil but it doesn't belong on Wikipedia") text(results["jimmy.default.1", "wbc_score"], results["jimmy.default.1", "click_rate"], labels="3", col=color.group.1); text(results["jimmy.default.2", "wbc_score"], results["jimmy.default.2", "click_rate"], labels="3", col=color.group.2); text(results["jimmy.default.3", "wbc_score"], results["jimmy.default.3", "click_rate"], labels="3", col=color.group.3); mtext(side=3, line=4, cex=cex.value, text="3: [Jimmy] Please read: A personal appeal from Wikipedia founder Jimmy Wales") text(results["sarah", "wbc_score"], results["sarah", "click_rate"], labels="4", col=color.group.1); mtext(side=3, line=3, cex=cex.value, text="4: [Sarah] Please read: A personal appea from an author of 159 Wikipedia articles") text(results["james", "wbc_score"], results["james", "click_rate"], labels="5", col=color.group.3); mtext(side=3, line=2, cex=cex.value, text="5: [James] Please read: A personal appeal from Wikipedia editor Dr. James Heilman") text(results["susan", "wbc_score"], results["susan", "click_rate"], labels="6", col=color.group.3); mtext(side=3, line=1, cex=cex.value, text="6: [Susan] Please read: A personal appeal from an author of 549 Wikipedia articles") dev.off();