Assignment function which distributes samples randomly.

assign_random(batch_container, samples = NULL)

Arguments

batch_container

Instance of BatchContainer class

samples

data.frame with samples.

Value

Returns a new BatchContainer.

Examples

samples <- data.frame(sampId = 1:3, sampName = letters[1:3])
samples
#>   sampId sampName
#> 1      1        a
#> 2      2        b
#> 3      3        c

bc <- BatchContainer$new(dimensions = c("row" = 3, "column" = 2))
bc
#> Batch container with 6 locations.
#>   Dimensions: row, column

set.seed(42)
# assigns samples randomly
bc <- assign_random(bc, samples)
bc$get_samples()
#> # A tibble: 6 × 4
#>     row column sampId sampName
#>   <int>  <int>  <int> <chr>   
#> 1     1      1      1 a       
#> 2     1      2     NA NA      
#> 3     2      1     NA NA      
#> 4     2      2     NA NA      
#> 5     3      1      2 b       
#> 6     3      2      3 c       

# assigns samples in order
bc <- assign_in_order(bc)
bc$get_samples()
#> # A tibble: 6 × 4
#>     row column sampId sampName
#>   <int>  <int>  <int> <chr>   
#> 1     1      1      1 a       
#> 2     1      2      2 b       
#> 3     2      1      3 c       
#> 4     2      2     NA NA      
#> 5     3      1     NA NA      
#> 6     3      2     NA NA