Skip to content

Instantly share code, notes, and snippets.

View davebraze's full-sized avatar

Dave Braze davebraze

View GitHub Profile
@davebraze
davebraze / block-randomize.R
Last active February 2, 2018 19:59
Block randomize a stimulus list with dplyr
library(dplyr)
## Toy data
df <- data_frame(block=rep(1:3, each=4), item=rep(1:4,3),
cond=rep(LETTERS[1:2], 6),
stim=paste0(rep(letters[1:2],6), rep(1:6,each=2)))
## Randomize blocks and trials within blocks
df.rand <- df %>%
group_by(block) %>%