| Title: | Experimental Design and Randomization Methods for Biomedical and Veterinary Research |
|---|---|
| Description: | Provides functions for generating randomized experimental designs for biomedical, veterinary, agricultural, and clinical research. The package includes functions for simple randomization, block randomization, stratified randomization, cluster randomization, Latin square designs, crossover designs, allocation summaries, schedule export, and visualization of treatment allocations. |
| Authors: | Vinodhkumar Obli Rajendran [aut, cre], Keerthi Aaradhana [aut] |
| Maintainer: | Vinodhkumar Obli Rajendran <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-09-26 09:58:59 UTC |
| Source: | https://github.com/vinodhpmd/expdesignr |
Summarizes treatment allocations from a randomization schedule.
allocation_summary(schedule, group_col = "Group")allocation_summary(schedule, group_col = "Group")
schedule |
A data frame or tibble produced by an ExpDesignR randomization function. |
group_col |
Name of the treatment group column. |
A tibble summarizing the number and percentage of subjects in each treatment group.
sch <- simple_randomization( n = 20, groups = c("Control","Treatment"), seed = 123 ) allocation_summary(sch)sch <- simple_randomization( n = 20, groups = c("Control","Treatment"), seed = 123 ) allocation_summary(sch)
Generates a randomized allocation schedule using fixed block randomization.
block_randomization(n, groups, block_size = 4, seed = NULL)block_randomization(n, groups, block_size = 4, seed = NULL)
n |
Total number of subjects. |
groups |
Character vector of treatment groups. |
block_size |
Size of each block. Must be a multiple of the number of treatment groups. |
seed |
Optional random seed. |
A tibble with subject allocation.
block_randomization( n = 24, groups = c("Control","Treatment"), block_size = 4, seed = 123 )block_randomization( n = 24, groups = c("Control","Treatment"), block_size = 4, seed = 123 )
Randomly assigns clusters (e.g., villages, farms, schools, hospitals) to treatment groups.
cluster_randomization(clusters, groups, seed = NULL)cluster_randomization(clusters, groups, seed = NULL)
clusters |
Character or numeric vector of cluster IDs. |
groups |
Character vector of treatment groups. |
seed |
Optional random seed. |
A tibble containing cluster assignments.
cluster_randomization( clusters = paste0("Farm_", 1:20), groups = c("Control", "Treatment"), seed = 123 )cluster_randomization( clusters = paste0("Farm_", 1:20), groups = c("Control", "Treatment"), seed = 123 )
Generates a crossover design for clinical, veterinary, pharmaceutical and agricultural experiments.
crossover_design( treatments, subjects, periods = length(treatments), seed = NULL )crossover_design( treatments, subjects, periods = length(treatments), seed = NULL )
treatments |
Character vector of treatment labels. |
subjects |
Number of subjects. |
periods |
Number of study periods. |
seed |
Optional random seed. |
A tibble containing the crossover schedule.
crossover_design( treatments = c("A","B"), subjects = 8, periods = 2, seed = 123 )crossover_design( treatments = c("A","B"), subjects = 8, periods = 2, seed = 123 )
Export a randomization schedule to a CSV file.
export_schedule(schedule, file = "allocation_schedule.csv", row.names = FALSE)export_schedule(schedule, file = "allocation_schedule.csv", row.names = FALSE)
schedule |
A data frame or tibble generated by ExpDesignR. |
file |
Character. Output CSV filename. |
row.names |
Logical. Should row names be written? |
Invisibly returns the input schedule.
sch <- simple_randomization( n = 20, groups = c("Control","Treatment"), seed = 123 ) ## Not run: export_schedule( sch, file = "allocation_schedule.csv" ) ## End(Not run)sch <- simple_randomization( n = 20, groups = c("Control","Treatment"), seed = 123 ) ## Not run: export_schedule( sch, file = "allocation_schedule.csv" ) ## End(Not run)
Generates a Latin Square design for experimental studies.
latin_square(treatments, randomize = TRUE, seed = NULL)latin_square(treatments, randomize = TRUE, seed = NULL)
treatments |
Character vector of treatment labels. |
randomize |
Logical. Should rows, columns and treatments be randomized? Default is TRUE. |
seed |
Optional random seed. |
A matrix representing a Latin square.
latin_square( treatments = LETTERS[1:4], seed = 123 )latin_square( treatments = LETTERS[1:4], seed = 123 )
Creates a bar chart showing the number of subjects allocated to each treatment group.
plot_randomization( schedule, group_col = "Group", fill = "#2C7FB8", title = "Treatment Allocation" )plot_randomization( schedule, group_col = "Group", fill = "#2C7FB8", title = "Treatment Allocation" )
schedule |
A data frame produced by ExpDesignR. |
group_col |
Character. Name of the treatment column. |
fill |
Character. Fill colour. |
title |
Character. Plot title. |
A ggplot object.
sch <- simple_randomization( n = 40, groups = c("Control","Treatment"), seed = 123 ) plot_randomization(sch)sch <- simple_randomization( n = 40, groups = c("Control","Treatment"), seed = 123 ) plot_randomization(sch)
Generate a simple random allocation schedule.
simple_randomization(n, groups, seed = NULL)simple_randomization(n, groups, seed = NULL)
n |
Number of subjects. |
groups |
Character vector of treatment groups. |
seed |
Optional random seed. |
A tibble containing subject IDs and assigned groups.
simple_randomization( n = 20, groups = c("Control", "Treatment"), seed = 123 )simple_randomization( n = 20, groups = c("Control", "Treatment"), seed = 123 )
Generates a randomized allocation schedule within each stratum.
stratified_randomization(data, strata, groups, seed = NULL)stratified_randomization(data, strata, groups, seed = NULL)
data |
A data frame containing the study subjects. |
strata |
Character vector specifying one or more stratification variables. |
groups |
Character vector of treatment groups. |
seed |
Optional random seed. |
A tibble containing the original data with an additional treatment allocation column.
df <- data.frame( ID = 1:20, Sex = rep(c("Male","Female"), each = 10), Age = rep(c("Young","Adult"), times = 10) ) stratified_randomization( data = df, strata = c("Sex"), groups = c("Control","Treatment"), seed = 123 )df <- data.frame( ID = 1:20, Sex = rep(c("Male","Female"), each = 10), Age = rep(c("Young","Adult"), times = 10) ) stratified_randomization( data = df, strata = c("Sex"), groups = c("Control","Treatment"), seed = 123 )