Type: Package
Title: Boxplot and Significance Test for Two Groups
Version: 0.1.0
Description: Provides functions to create side-by-side boxplots for a continuous variable grouped by a two-level categorical variable, check normality assumptions using the Shapiro-Wilk test (Shapiro and Wilk (1965) <doi:10.2307/2333709>), and perform appropriate statistical tests such as the independent two-sample t-test (Student (1908) <doi:10.1093/biomet/6.1.1>) or the Mann–Whitney U test ( Mann–Whitney (1947) <doi:10.1214/aoms/1177730491>). Returns a publication-ready plot and test statistics including test statistic, degrees of freedom, and p-value.
License: MIT + file LICENSE
Encoding: UTF-8
Depends: R (≥ 4.1.0)
Imports: ggplot2, dplyr, stats, rlang
Suggests: testthat (≥ 3.0.0), knitr, rmarkdown
VignetteBuilder: knitr
RoxygenNote: 7.3.3
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2025-09-24 11:39:52 UTC; arka
Author: Arkaprabha Sau [aut, cre], Santanu Phadikar [aut], Ishita Bhakta [aut]
Maintainer: Arkaprabha Sau <arka.doctor@gmail.com>
Repository: CRAN
Date/Publication: 2025-10-01 07:00:16 UTC

Compare Two Groups with Boxplot and Significance Test

Description

Generates side-by-side boxplots and runs Shapiro-Wilk tests by group to check for normality. If both groups are normally distributed, an independent two-sample t-test is applied. Otherwise, a Mann–Whitney U test (Wilcoxon rank-sum test) is performed. Returns a structured list with plots and a clear test summary.

Usage

compare_two_groups(data, continuous, group)

Arguments

data

A data.frame containing the variables.

continuous

Name of continuous variable (string).

group

Name of categorical variable with exactly 2 levels (string).

Value

A list containing:

plot

A ggplot object of the boxplot with jittered points.

normality

A data.frame showing Shapiro-Wilk test results by group.

test_summary

A data.frame summarizing the statistical test used, statistic, df (if applicable), and p-value.

Examples

res <- compare_two_groups(mtcars, "mpg", "am")
res$plot
res$normality
res$test_summary