| Type: | Package |
| Title: | Experimental Design and Randomization Methods for Biomedical and Veterinary Research |
| Version: | 0.1.0 |
| Description: | Generates randomized experimental designs for biomedical, veterinary, agricultural, and clinical research, including simple, block, stratified, and cluster randomization, Latin square and crossover designs, allocation summaries, schedule export, and visualization of treatment allocations. The methods are based on established principles of randomization and experimental design; see Rosenberger and Lachin (2015, ISBN:9781118742242) and Jones and Kenward (2014, ISBN:9781439861424). |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.2.0) |
| Imports: | stats, utils, tibble, dplyr, ggplot2, rlang |
| Suggests: | testthat (≥ 3.0.0), covr, spelling, knitr, rmarkdown |
| URL: | https://github.com/vinodhpmd/ExpDesignR |
| BugReports: | https://github.com/vinodhpmd/ExpDesignR/issues |
| Language: | en-US |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | no |
| Config/roxygen2/version: | 8.1.0 |
| VignetteBuilder: | knitr |
| Packaged: | 2026-08-21 07:53:39 UTC; m |
| Author: | Vinodhkumar Obli Rajendran [aut, cre], Keerthi Aaradhana [aut] |
| Maintainer: | Vinodhkumar Obli Rajendran <vinodhkumar.rajendran@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-08-27 10:30:08 UTC |
Allocation Summary
Description
Summarizes treatment allocations from a randomization schedule.
Usage
allocation_summary(schedule, group_col = "Group")
Arguments
schedule |
A data frame or tibble produced by an ExpDesignR randomization function. |
group_col |
Name of the treatment group column. |
Value
A tibble summarizing the number and percentage of subjects in each treatment group.
Examples
sch <- simple_randomization(
n = 20,
groups = c("Control","Treatment"),
seed = 123
)
allocation_summary(sch)
Block Randomization
Description
Generates a randomized allocation schedule using fixed block randomization.
Usage
block_randomization(n, groups, block_size = 4, seed = NULL)
Arguments
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. |
Value
A tibble with subject allocation.
Examples
block_randomization(
n = 24,
groups = c("Control","Treatment"),
block_size = 4,
seed = 123
)
Cluster Randomization
Description
Randomly assigns clusters (e.g., villages, farms, schools, hospitals) to treatment groups.
Usage
cluster_randomization(clusters, groups, seed = NULL)
Arguments
clusters |
Character or numeric vector of cluster IDs. |
groups |
Character vector of treatment groups. |
seed |
Optional random seed. |
Value
A tibble containing cluster assignments.
Examples
cluster_randomization(
clusters = paste0("Farm_", 1:20),
groups = c("Control", "Treatment"),
seed = 123
)
Crossover Design
Description
Generates a crossover design for clinical, veterinary, pharmaceutical and agricultural experiments.
Usage
crossover_design(
treatments,
subjects,
periods = length(treatments),
seed = NULL
)
Arguments
treatments |
Character vector of treatment labels. |
subjects |
Number of subjects. |
periods |
Number of study periods. |
seed |
Optional random seed. |
Value
A tibble containing the crossover schedule.
Examples
crossover_design(
treatments = c("A","B"),
subjects = 8,
periods = 2,
seed = 123
)
Export Randomization Schedule
Description
Export a randomization schedule to a CSV file.
Usage
export_schedule(schedule, file, row.names = FALSE)
Arguments
schedule |
A data frame or tibble generated by ExpDesignR. |
file |
Character. Output CSV filename or path. This argument must be supplied explicitly. |
row.names |
Logical. Should row names be written? |
Value
Invisibly returns the input schedule unchanged.
The function writes the schedule to the CSV file specified by
file.
Examples
sch <- simple_randomization(
n = 20,
groups = c("Control", "Treatment"),
seed = 123
)
tf <- tempfile(fileext = ".csv")
export_schedule(
sch,
file = tf
)
unlink(tf)
Latin Square Design
Description
Generates a Latin Square design for experimental studies.
Usage
latin_square(treatments, randomize = TRUE, seed = NULL)
Arguments
treatments |
Character vector of treatment labels. |
randomize |
Logical. Should rows, columns and treatments be randomized? Default is TRUE. |
seed |
Optional random seed. |
Value
A matrix representing a Latin square.
Examples
latin_square(
treatments = LETTERS[1:4],
seed = 123
)
Plot Randomization Schedule
Description
Creates a bar chart showing the number of subjects allocated to each treatment group.
Usage
plot_randomization(
schedule,
group_col = "Group",
fill = "#2C7FB8",
title = "Treatment Allocation"
)
Arguments
schedule |
A data frame produced by ExpDesignR. |
group_col |
Character. Name of the treatment column. |
fill |
Character. Fill colour. |
title |
Character. Plot title. |
Value
A ggplot object.
Examples
sch <- simple_randomization(
n = 40,
groups = c("Control","Treatment"),
seed = 123
)
plot_randomization(sch)
Simple Randomization
Description
Generate a simple random allocation schedule.
Usage
simple_randomization(n, groups, seed = NULL)
Arguments
n |
Number of subjects. |
groups |
Character vector of treatment groups. |
seed |
Optional random seed. |
Value
A tibble containing subject IDs and assigned groups.
Examples
simple_randomization(
n = 20,
groups = c("Control", "Treatment"),
seed = 123
)
Stratified Randomization
Description
Generates a randomized allocation schedule within each stratum.
Usage
stratified_randomization(data, strata, groups, seed = NULL)
Arguments
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. |
Value
A tibble containing the original data with an additional treatment allocation column.
Examples
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
)