Skip to content

Instantly share code, notes, and snippets.

@debruine
Created May 14, 2019 14:01
Show Gist options
  • Save debruine/9051c6fa4f7ec8b8568c72d5bd851d00 to your computer and use it in GitHub Desktop.
Save debruine/9051c6fa4f7ec8b8568c72d5bd851d00 to your computer and use it in GitHub Desktop.
Example design spec for scienceverse
library(faux)
within <- list(
pet = c("dog" = "Has a dog", "cat" = "Has a cat"),
time = c("day" = "Tested during the day", "night" = "Tested at night")
)
wcells <- faux:::cell_combos(within)
between <- list(
country = c("UK" = "United Kingdom", "NL" = "Nederland"),
condition = c("A" = "Condition A", "B" = "Condition B")
)
bcells <- faux:::cell_combos(between)
n <- 50 # per cell
mu <- matrix(c(1:4, 4:1, 1:4, 4:1),
nrow = length(wcells),
ncol = length(bcells),
dimnames = list(wcells, bcells))
sd <- 1
r <- list(
UK_A = 0.5,
UK_B = 0.25,
NL_A = 0.75,
NL_B = 0.5
)
design <- check_design(within, between, n, mu, sd, r)
jsonlite::toJSON(design, auto_unbox = TRUE, pretty = TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment