The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Getting Started with ExpDesignR

Simple and blocked randomization

simple_randomization(20, c("Control", "Treatment"), seed = 123)
#> # A tibble: 20 × 2
#>    Subject Group    
#>      <int> <chr>    
#>  1       1 Treatment
#>  2       2 Control  
#>  3       3 Treatment
#>  4       4 Control  
#>  5       5 Control  
#>  6       6 Treatment
#>  7       7 Control  
#>  8       8 Control  
#>  9       9 Control  
#> 10      10 Treatment
#> 11      11 Control  
#> 12      12 Treatment
#> 13      13 Control  
#> 14      14 Control  
#> 15      15 Treatment
#> 16      16 Control  
#> 17      17 Treatment
#> 18      18 Treatment
#> 19      19 Treatment
#> 20      20 Control
block_randomization(24, c("Control", "Treatment"), block_size = 4, seed = 123)
#> # A tibble: 24 × 3
#>    Subject Block Group    
#>      <int> <int> <chr>    
#>  1       1     1 Treatment
#>  2       2     1 Treatment
#>  3       3     1 Control  
#>  4       4     1 Control  
#>  5       5     2 Treatment
#>  6       6     2 Control  
#>  7       7     2 Treatment
#>  8       8     2 Control  
#>  9       9     3 Treatment
#> 10      10     3 Control  
#> # ℹ 14 more rows
variable_block_randomization(30, c("Control", "Treatment"), c(4, 6, 8), seed = 123)
#> # A tibble: 30 × 4
#>    Subject Block BlockSize Group    
#>      <int> <int>     <int> <chr>    
#>  1       1     1         8 Control  
#>  2       2     1         8 Control  
#>  3       3     1         8 Treatment
#>  4       4     1         8 Treatment
#>  5       5     1         8 Control  
#>  6       6     1         8 Treatment
#>  7       7     1         8 Treatment
#>  8       8     1         8 Control  
#>  9       9     2         8 Control  
#> 10      10     2         8 Control  
#> # ℹ 20 more rows

Stratified and adaptive randomization

dat <- data.frame(
  ID = 1:40,
  Sex = rep(c("Male", "Female"), 20),
  Site = rep(c("A", "B"), each = 20)
)
stratified_randomization(dat, c("Sex", "Site"), c("Control", "Treatment"), seed = 123)
#> # A tibble: 40 × 5
#>       ID Sex    Site  Treatment Stratum  
#>    <int> <chr>  <chr> <chr>     <chr>    
#>  1     1 Male   A     Control   Male::A  
#>  2     2 Female A     Treatment Female::A
#>  3     3 Male   A     Control   Male::A  
#>  4     4 Female A     Control   Female::A
#>  5     5 Male   A     Control   Male::A  
#>  6     6 Female A     Treatment Female::A
#>  7     7 Male   A     Control   Male::A  
#>  8     8 Female A     Control   Female::A
#>  9     9 Male   A     Control   Male::A  
#> 10    10 Female A     Control   Female::A
#> # ℹ 30 more rows
stratified_block_randomization(dat, c("Sex", "Site"), c("Control", "Treatment"), 4, seed = 123)
#> # A tibble: 40 × 6
#>       ID Sex    Site  Treatment Stratum   Block
#>    <int> <chr>  <chr> <chr>     <chr>     <int>
#>  1     1 Male   A     Control   Male::A       7
#>  2     2 Female A     Treatment Female::A     1
#>  3     3 Male   A     Treatment Male::A       7
#>  4     4 Female A     Treatment Female::A     1
#>  5     5 Male   A     Treatment Male::A       7
#>  6     6 Female A     Control   Female::A     1
#>  7     7 Male   A     Control   Male::A       7
#>  8     8 Female A     Control   Female::A     1
#>  9     9 Male   A     Treatment Male::A       8
#> 10    10 Female A     Treatment Female::A     2
#> # ℹ 30 more rows
minimization_randomization(dat, c("Sex", "Site"), seed = 123)
#> # A tibble: 40 × 4
#>       ID Sex    Site  Treatment
#>    <int> <chr>  <chr> <chr>    
#>  1     1 Male   A     Control  
#>  2     2 Female A     Treatment
#>  3     3 Male   A     Treatment
#>  4     4 Female A     Control  
#>  5     5 Male   A     Control  
#>  6     6 Female A     Treatment
#>  7     7 Male   A     Control  
#>  8     8 Female A     Control  
#>  9     9 Male   A     Control  
#> 10    10 Female A     Control  
#> # ℹ 30 more rows

Other designs

completely_randomized_design(20, c("A", "B"), seed = 123)
#> # A tibble: 20 × 2
#>     Unit Treatment
#>    <int> <chr>    
#>  1     1 B        
#>  2     2 A        
#>  3     3 B        
#>  4     4 A        
#>  5     5 A        
#>  6     6 B        
#>  7     7 A        
#>  8     8 A        
#>  9     9 A        
#> 10    10 B        
#> 11    11 A        
#> 12    12 B        
#> 13    13 A        
#> 14    14 A        
#> 15    15 B        
#> 16    16 A        
#> 17    17 B        
#> 18    18 B        
#> 19    19 B        
#> 20    20 A
randomized_block_design(24, c("A", "B"), block_size = 4, seed = 123)
#> # A tibble: 24 × 3
#>     Unit Block Treatment
#>    <int> <int> <chr>    
#>  1     1     1 B        
#>  2     2     1 B        
#>  3     3     1 A        
#>  4     4     1 A        
#>  5     5     2 B        
#>  6     6     2 A        
#>  7     7     2 B        
#>  8     8     2 A        
#>  9     9     3 B        
#> 10    10     3 A        
#> # ℹ 14 more rows
factorial_design(list(Dose = c("Low", "High"), Diet = c("A", "B")), replicates = 2, seed = 123)
#>     Unit Dose Diet
#> 4      1 High    B
#> 4.1    2 High    B
#> 2      3 High    A
#> 3.1    4  Low    B
#> 1.1    5  Low    A
#> 2.1    6 High    A
#> 3      7  Low    B
#> 1      8  Low    A
latin_square(LETTERS[1:4], seed = 123)
#>       Col_1 Col_2 Col_3 Col_4
#> Row_1 "C"   "D"   "A"   "B"  
#> Row_2 "A"   "C"   "B"   "D"  
#> Row_3 "B"   "A"   "D"   "C"  
#> Row_4 "D"   "B"   "C"   "A"
crossover_design(c("A", "B"), subjects = 8, periods = 2, seed = 123)
#> # A tibble: 8 × 3
#>   Subject Period_1 Period_2
#>     <int> <chr>    <chr>   
#> 1       1 A        B       
#> 2       2 A        B       
#> 3       3 A        B       
#> 4       4 B        A       
#> 5       5 A        B       
#> 6       6 B        A       
#> 7       7 B        A       
#> 8       8 B        A

Allocation utilities

sch <- simple_randomization(40, c("Control", "Treatment"), seed = 123)
allocation_summary(sch)
#> # A tibble: 2 × 3
#>   Group     Count Percentage
#>   <chr>     <int>      <dbl>
#> 1 Control      24         60
#> 2 Treatment    16         40
plot_randomization(sch)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.