Add between factors

add_between(.data, .by = NULL, ..., .shuffle = FALSE, .prob = NULL)

Arguments

.data

the data frame

.by

the grouping column (groups by row if NULL)

...

the names and levels of the new factors

.shuffle

whether to assign cells randomly or in "order"

.prob

probability of each level, equal if NULL

Value

data frame

Examples

add_random(subj = 4, item = 2) %>% add_between("subj", condition = c("cntl", "test")) %>% add_between("item", version = c("A", "B"))
#> # A tibble: 8 x 4 #> subj item condition version #> <chr> <chr> <fct> <fct> #> 1 s1 i1 cntl A #> 2 s1 i2 cntl B #> 3 s2 i1 test A #> 4 s2 i2 test B #> 5 s3 i1 cntl A #> 6 s3 i2 cntl B #> 7 s4 i1 test A #> 8 s4 i2 test B