Skip to contents

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.

Value

An edibble design.

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  vaccine2
#>  2  subject2  vaccine1
#>  3  subject3  vaccine1
#>  4  subject4  vaccine2
#>  5  subject5  vaccine2
#>  6  subject6  vaccine1
#>  7  subject7  vaccine1
#>  8  subject8  vaccine2
#>  9  subject9  vaccine2
#> 10  subject10 vaccine1

# 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     block2
#>  2  subject2     block1
#>  3  subject3     block1
#>  4  subject4     block2
#>  5  subject5     block1
#>  6  subject6     block2
#>  7  subject7     block1
#>  8  subject8     block2
#>  9  subject9     block1
#> 10  subject10    block2
#> 11  subject11    block2
#> 12  subject12    block1
#> 13  subject13    block2
#> 14  subject14    block1
#> 15  subject15    block1
#> 16  subject16    block2
#> 17  subject17    block1
#> 18  subject18    block2
#> 19  subject19    block1
#> 20  subject20    block2