Skip to content

Instantly share code, notes, and snippets.

@jmcarp
Last active December 15, 2015 08:58
Show Gist options
  • Save jmcarp/5234431 to your computer and use it in GitHub Desktop.
Save jmcarp/5234431 to your computer and use it in GitHub Desktop.
# data = ...
# subjects = ...
# trials = ...
# computation = function(...)
for (subject in subjects) {
subject_rows = data$subject == subject
for (trial in trials) {
rows = subject_rows & data$trial == trial
result = computation(data[rows,])
data$result[rows,] = result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment