This file contains hidden or 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
# from: http://learnr.wordpress.com/2010/01/21/ggplot2-crayola-crayon-colours/ | |
library(XML) | |
library(ggplot2) | |
theurl <- "http://en.wikipedia.org/wiki/List_of_Crayola_crayon_colors" | |
html <- htmlParse(theurl) | |
sched <- readHTMLTable(html, stringsAsFactors = FALSE) | |
crayola <- readHTMLTable(html, stringsAsFactors = FALSE)[[2]] | |
crayola <- crayola[, c("Hex Code", "Issued", "Retired")] | |
names(crayola) <- c("colour", "issued", "retired") |
This file contains hidden or 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
entity.write <- function(x){ | |
out = as.character(x) | |
out = paste("\"", x, "\"", sep="") | |
out | |
} | |
toJSONdf <- function(x){ | |
str = "[" | |
for(row in 1:(dim(x)[1])){ | |
first_entry = TRUE |
This file contains hidden or 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
<script> | |
function rand(){ | |
if (Math.random() > .5){ | |
document.getElementById('boss').style.visibility="hidden"; | |
} else { | |
document.getElementById('requester').style.visibility="hidden"; | |
} | |
} | |
</script> |
This file contains hidden or 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
library(ggplot2) | |
library(reldist) | |
data <- read.csv("User_3144_workers.csv") | |
u = dim(data)[1] | |
png("mturk_distro.png") | |
qplot(Number.of.HITs.approved.or.rejected, data = data) + scale_x_log2() + | |
xlab("Number of HITs Approved or Rejected \n (John Horton's Account)") + | |
ylab("Count of MTurk Workers") + |
This file contains hidden or 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
<script src="http://code.jquery.com/jquery-1.4.4.js"></script> <script> | |
$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?", | |
{ | |
tags: "cat", | |
tagmode: "any", | |
format: "json" | |
}, | |
function(data) { | |
$.each(data.items, function(i,item){ | |
$("<img/>").attr("src", item.media.m).appendTo("#images"); |
This file contains hidden or 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
accept_time <- sapply(results$AcceptTime, | |
function(t){as.numeric(as.POSIXct(as.character(t), "%a %b %d %H:%M:%S GMT %Y", tz="UTC"))} | |
) |
This file contains hidden or 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
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js"></script> | |
<p><style type="text/css"> | |
/* | |
* jQuery UI CSS Framework 1.8.6 | |
* | |
* Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) | |
* Dual licensed under the MIT or GPL Version 2 licenses. | |
* http://jquery.org/license | |
* | |
* http://docs.jquery.com/UI/Theming/API |
This file contains hidden or 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
# accept time would be seconds from the unix epoch | |
results$rank <- mapply( | |
function(time,worker_id){ | |
which(time==sort(subset(results, WorkerId==worker_id)$accept_time)) | |
}, results$accept_time, results$WorkerId) |
This file contains hidden or 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
# keys and values map 1:1 | |
# e.g., | |
keys <- c(1,2,3) | |
values <- c('a','b','c') | |
list_of_keys <- c(1,2,3,1,1,2) | |
letters <- sapply(list_of_keys, function(x){values[which(x==keys)]}) |
This file contains hidden or 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
unix2POSIXct <- function (time) structure(time, class = c("POSIXt", "POSIXct")) |
OlderNewer