This function assigns specific treatment or unit levels to actual units.
Usage
assign_trts(
.design,
order = "random",
seed = NULL,
constrain = nesting_structure(.design),
...,
.record = TRUE
)
assign_units(
.design,
order = "random",
seed = NULL,
constrain = nesting_structure(.design),
...,
.record = TRUE
)
Arguments
- .design
An edibble design which should have units, treatments and allotment defined.
- order
A character vector signifying the apportion of treatments to units. The value should be either "random", "systematic" or "systematic-random". "random" allocates the treatment randomly to units based on specified allotment with restrictions implied by unit structure. "systematic" allocates the treatment in a systematic order to units. "systematic-random" allocates the treatment in a systematic order to units but where it is not possible to divide treatments equally (as the number of units are not divisible by the number of levels of the treatment factor), then the extras are chosen randomly.
- seed
A scalar value used to set the seed so that the result is reproducible.
- constrain
The nesting structure for units.
- ...
Arguments parsed into
order_trts
functions.- .record
Whether to record the step.
Examples
# 10 subject, 2 vaccine treatments
design() %>%
set_units(subject = 10) %>%
set_trts(vaccine = 2) %>%
allot_trts(vaccine ~ subject) %>%
assign_trts() %>%
serve_table()
#> # An edibble: 10 x 2
#> subject vaccine
#> <unit(10)> <trt(2)>
#> 1 subject1 vaccine1
#> 2 subject2 vaccine2
#> 3 subject3 vaccine1
#> 4 subject4 vaccine1
#> 5 subject5 vaccine2
#> 6 subject6 vaccine1
#> 7 subject7 vaccine2
#> 8 subject8 vaccine2
#> 9 subject9 vaccine1
#> 10 subject10 vaccine2
# 20 subjects, 2 blocks, assign subjects to blocks
design() %>%
set_units(subject = 20,
block = 2) %>%
allot_units(block ~ subject) %>%
assign_units() %>%
serve_table()
#> # An edibble: 20 x 2
#> subject block
#> <unit(20)> <unit(2)>
#> 1 subject1 block1
#> 2 subject2 block2
#> 3 subject3 block2
#> 4 subject4 block1
#> 5 subject5 block1
#> 6 subject6 block2
#> 7 subject7 block1
#> 8 subject8 block2
#> 9 subject9 block2
#> 10 subject10 block1
#> 11 subject11 block2
#> 12 subject12 block1
#> 13 subject13 block1
#> 14 subject14 block2
#> 15 subject15 block1
#> 16 subject16 block2
#> 17 subject17 block1
#> 18 subject18 block2
#> 19 subject19 block2
#> 20 subject20 block1