This function sets new edibble variables of class edbl_unit. More specifically, this means that new nodes are added to the edbl_graph.

set_units(
  .edibble,
  ...,
  .name_repair = c("check_unique", "unique", "universal", "minimal")
)

Arguments

.edibble

An edibble design (EdibbleDesign), an edibble data frame (edbl_table) or an object that contains the edibble data frame in the attribute design.

...

Either a name-value pair or a series of the names.

.name_repair

Same as the argument in tibble::tibble().

Definition of unit

A unit, much like factor, is an over-used word but due to lack of a better word, edibble uses the word "unit" to refer to any entity, physical or otherwise, that pertain to the experiment. This function doen't explicitly distinguish between experimental or observational units, nor is a unit limited to these type of units. A unit in edibble can be a blocking factor or even a discrete time unit.

Limitations

Currently a unit should only have a discrete set of levels and you need to know the number of levels prior to setting the units.

See also

Examples

# 30 rats start_design() %>% set_units(rat = 30) %>% serve_table()
#> # An edibble: 30 x 1 #> rat #> <unit(30)> #> 1 rat1 #> 2 rat2 #> 3 rat3 #> 4 rat4 #> 5 rat5 #> 6 rat6 #> 7 rat7 #> 8 rat8 #> 9 rat9 #> 10 rat10 #> # … with 20 more rows
# 4 girls named "Anna", "Betty", "Carol", "Diana" start_design() %>% set_units(girl = c("Anna", "Betty", "Carol", "Diana")) %>% serve_table()
#> # An edibble: 4 x 1 #> girl #> <unit(4)> #> 1 Anna #> 2 Betty #> 3 Carol #> 4 Diana
# 3 companies, with 10 boxes each start_design() %>% set_units(company = c("A", "B", "C"), box = nested_in(company, 10))
#> An edibble design #> └─company (3 levels) #> └─box (30 levels)
# 2 classes, one with 10 students, the other with 20 students start_design() %>% set_units(class = 2, student = nested_in(class, 1 ~ 10, 2 ~ 20))
#> An edibble design #> └─class (2 levels) #> └─student (30 levels)
# 4 countries with 10 people from Australia & New Zealand and 20 from the rest start_design() %>% set_units(country = c("AU", "NZ", "USA", "JPN"), person = nested_in(country, c("AU", "NZ") ~ 10, . ~ 20)) %>% serve_table()
#> # An edibble: 60 x 2 #> country person #> <unit(4)> <unit(60)> #> 1 AU person1 #> 2 AU person2 #> 3 AU person3 #> 4 AU person4 #> 5 AU person5 #> 6 AU person6 #> 7 AU person7 #> 8 AU person8 #> 9 AU person9 #> 10 AU person10 #> # … with 50 more rows
# if using existing data then it specifies which variables are units lady_tasting_tea %>% set_units(cup)
#> Error: .edibble is not an edibble.