The boxTest package provides a simple workflow for comparing two groups using boxplots and statistical tests. It automatically:
Checks normality via Shapiro–Wilk test.
Applies the appropriate test:
Returns a publication-ready boxplot with optional jittered points.
We will use the built-in mtcars
dataset to compare
mpg between automatic (am = 0
) and manual
(am = 1
) cars.
# Load package
library(boxTest)
# Compare mpg between automatic and manual cars
res <- compare_two_groups(mtcars, "mpg", "am")
# Display the boxplot
res$plot
The function also returns the Shapiro-Wilk normality test results for each group.
Finally, the package provides a summary of the statistical test applied, including test statistic, degrees of freedom, and p-value.
The boxTest package streamlines exploratory analysis and significance testing for two-group comparisons in R. It is particularly useful for beginners and provides a clear, publication-ready output.