Skip to content

Instantly share code, notes, and snippets.

@earcanal
Last active August 6, 2018 10:27
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 earcanal/3e705805cc8b92ccc4a12a94b66bae6f to your computer and use it in GitHub Desktop.
Save earcanal/3e705805cc8b92ccc4a12a94b66bae6f to your computer and use it in GitHub Desktop.
Randomise experiment factory participants by token
# $ ssh $HOST 'docker exec container expfactory users --list' | grep active | cut -f 2 | perl -lne's/(.*)\[active\]/$1/g; print' > docker/tokens
library(tidyverse)
tokens <- read.table('data/tokens') %>%
rename(token = V1)
N=nrow(tokens)
set.seed(54321)
participants <- expand.grid(k=1:N, condition=c("experimental","control")) %>%
mutate(r = runif(n())) %>%
arrange(r) %>%
head(N)
participants$p <- seq.int(nrow(participants))
participants <- cbind(participants, tokens) %>%
select(p,condition,token)
participants %>%
group_by(condition) %>%
summarise(count = length(condition))
write.csv(participants, file='data/participants.csv', row.names = FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment