Skip to content

Instantly share code, notes, and snippets.

@johnjosephhorton
Created May 21, 2011 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnjosephhorton/984913 to your computer and use it in GitHub Desktop.
Save johnjosephhorton/984913 to your computer and use it in GitHub Desktop.
functional programming way to extract the within-subject order that some time-stamped event occurred
# 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment