assign_fcts {edibble}R Documentation

Assign treatments or units to units

Description

This function assigns specific treatment or unit levels to actual units.

Usage

assign_trts(
  .edibble,
  order = "random",
  seed = NULL,
  constrain = nesting_structure(.edibble),
  ...,
  .record = TRUE
)

assign_units(
  .edibble,
  order = "random",
  seed = NULL,
  constrain = nesting_structure(.edibble),
  ...,
  .record = TRUE
)

Arguments

.edibble

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-fastest", "systematic-slowest", "systematic-random-fastest", "systematic-random-slowest" or a class name corresponding to the algorithm for order_trts(). "random" allocates the treatment randomly to units based on specified allotment with restrictions implied by unit structure. "systematic-slowest" allocates the treatment in a systematic order to units such that the treatment level is slow in varying. In contrast, "systematic-fastest" is fast in varying for treatment levels. "systematic-random-fastest" and "systematic-random-slowest" 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()

# 20 subjects, 2 blocks, assign subjects to blocks
design() %>%
  set_units(subject = 20,
            block = 2) %>%
  allot_units(block ~ subject) %>%
  assign_units() %>%
  serve_table()

[Package edibble version 1.1.0 Index]