Form groups and subgroups of 'homogeneous' samples as defined by certain variables and size constraints

form_homogeneous_subgroups(
  batch_container,
  allocate_var,
  keep_together_vars = c(),
  n_min = NA,
  n_max = NA,
  n_ideal = NA,
  subgroup_var_name = NULL,
  prefer_big_groups = TRUE,
  strict = TRUE
)

Arguments

batch_container

Batch container with all samples assigned that are to be grouped and sub-grouped

allocate_var

Name of a variable in the samples table to inform possible groupings, as (sub)group sizes must add up to the correct totals

keep_together_vars

Vector of column names in sample table; groups are formed by pooling samples with identical values of all those variables

n_min

Minimal number of samples in one sub(!)group; by default 1

n_max

Maximal number of samples in one sub(!)group; by default the size of the biggest group

n_ideal

Ideal number of samples in one sub(!)group; by default the floor or ceiling of mean(n_min,n_max), depending on the setting of prefer_big_groups

subgroup_var_name

An optional column name for the subgroups which are formed (or NULL)

prefer_big_groups

Boolean; indicating whether or not bigger subgroups should be preferred in case of several possibilities

strict

Boolean; if TRUE, subgroup size constraints have to be met strictly, implying the possibility of finding no solution at all

Value

Subgroup object to be used in subsequent calls to compile_possible_subgroup_allocation()