| Title: | Automated Statistical Analysis, Visualization and Multi-Format Narrative Reporting |
|---|---|
| Description: | Provides automated statistical analysis, rich visualization, and multi-format narrative reporting through a unified pipeline. Descriptive statistics are available via easy_describe() and easy_group_summary(). Inferential tests with plain-language narratives are provided by easy_regression(), easy_logistic_regression(), easy_ttest(), easy_anova(), easy_chisq(), easy_ztest(), easy_ftest(), easy_correlation(), easy_wilcox(), and easy_kruskal(). Publication-ready 'ggplot2' visualizations are produced by easy_histogram(), easy_boxplot(), easy_scatter(), easy_barplot(), easy_qqplot(), easy_density(), easy_correlation_heatmap(), easy_regression_diagnostics(), and easy_odds_ratio_plot(). The core Narrative Generator Module applies conditional logic to extracted p-values, effect sizes, and model-fit metrics to produce statistically sound, human-readable explanations automatically. Results render in the 'RStudio' Viewer (HTML), the console (ASCII), or export directly to Microsoft Word via 'flextable' and 'officer'. |
| Authors: | Mahesh Divakaran [aut, cre] (Affiliation: Amity School of Applied Sciences, Amity University Lucknow), Gunjan Singh [aut] (Affiliation: Amity School of Applied Sciences, Amity University Lucknow), Jayadevan Shreedharan [aut] (Affiliation: Gulf Medical University) |
| Maintainer: | Mahesh Divakaran <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 2.0.0 |
| Built: | 2026-05-25 06:40:19 UTC |
| Source: | https://github.com/itsmdivakaran/easystat |
EasyStat provides a unified pipeline for automated statistical analysis and plain-language narrative reporting in R. The four-step pipeline — Core Statistical Engine, Metric Extractor (broom), Narrative Generator Module, and Unified Result Object — transforms raw data into publication-ready output with a single function call.
Descriptive statistics:
easy_describe, easy_group_summary
Inferential tests:
easy_regression, easy_ttest,
easy_anova, easy_chisq,
easy_ztest, easy_ftest,
easy_correlation
Visualizations:
easy_histogram, easy_boxplot,
easy_scatter, easy_barplot,
easy_qqplot, easy_density,
easy_correlation_heatmap, easy_autoplot
Reporting:
export_to_word, theme_easystat
Mahesh Divakaran (Amity School of Applied Sciences, Amity University Lucknow), Gunjan Singh (Amity School of Applied Sciences, Amity University Lucknow), Jayadevan Shreedharan (Gulf Medical University)
Maintainer: Mahesh Divakaran [email protected] (Amity School of Applied Sciences, Amity University Lucknow)
Authors:
Gunjan Singh (Amity School of Applied Sciences, Amity University Lucknow)
Jayadevan Shreedharan (Gulf Medical University)
Useful links:
Report bugs at https://github.com/itsmdivakaran/Easystat/issues
Executes a one-way ANOVA using stats::aov(), extracts key metrics
via broom, computes eta-squared as an effect-size measure, and
generates a plain-language narrative via the Narrative Generator Module.
easy_anova(formula, data, alpha = 0.05)easy_anova(formula, data, alpha = 0.05)
formula |
A |
data |
A data frame containing the variables in |
alpha |
Significance threshold for the narrative. Default |
An object of class "easystat_result" with:
test_typeCharacter: "anova"
formula_strCharacter string of the formula used
raw_modelThe raw aov object
coefficients_tableANOVA table (SS, df, MS, F, p)
model_fit_tableSummary metrics (F-statistic, eta-squared, p-value)
explanationPlain-language narrative string
result <- easy_anova(Sepal.Length ~ Species, data = iris) print(result)result <- easy_anova(Sepal.Length ~ Species, data = iris) print(result)
Chooses the most appropriate plot type based on the test_type of an
easystat_result object and renders it.
easy_autoplot(result, data = NULL, ...)easy_autoplot(result, data = NULL, ...)
result |
An |
data |
The original data frame (required for some plot types). |
... |
Additional arguments passed to the underlying plot function. |
An "easystat_result" plot object, invisibly.
Creates a frequency bar chart for categorical variables, or a mean-and-error bar chart for numeric outcomes grouped by a factor.
easy_barplot( x, data, group_by = NULL, stat = c("count", "mean"), fill_palette = NULL, title = NULL )easy_barplot( x, data, group_by = NULL, stat = c("count", "mean"), fill_palette = NULL, title = NULL )
x |
Column name of the variable to plot. |
data |
A data frame. |
group_by |
Optional grouping column for grouped frequency bars. |
stat |
|
fill_palette |
Color palette vector. Default EasyStat palette. |
title |
Custom plot title. |
An "easystat_result" object with plot_object.
Produces a boxplot for one variable, optionally grouped by a factor. Adds a jittered dot overlay, labels each group's median, and highlights outliers.
easy_boxplot(formula, data, fill_palette = NULL, notch = FALSE, title = NULL)easy_boxplot(formula, data, fill_palette = NULL, notch = FALSE, title = NULL)
formula |
A formula: |
data |
A data frame. |
fill_palette |
Character vector of fill colors. Default EasyStat palette. |
notch |
Logical; draw notched boxes? Default |
title |
Custom plot title. |
An "easystat_result" object with plot_object.
Runs either a chi-square test of independence (two categorical variables) or a goodness-of-fit test (one variable vs. expected proportions), extracts Cramér's V as the effect-size measure, and generates a plain-language narrative via the Narrative Generator Module.
easy_chisq(x, y = NULL, data = NULL, p = NULL, correct = TRUE, alpha = 0.05)easy_chisq(x, y = NULL, data = NULL, p = NULL, correct = TRUE, alpha = 0.05)
x |
A factor/character vector, OR a contingency table (matrix), OR a
formula |
y |
A factor/character vector (second categorical variable) for the
independence test. Ignored when |
data |
A data frame. Required when |
p |
Numeric vector of expected probabilities for the GOF test.
If |
correct |
Logical; apply Yates' continuity correction? Default |
alpha |
Significance threshold for narrative. Default |
An "easystat_result" object with:
coefficients_tableObserved vs. expected frequency table
model_fit_tableChi-square statistic, df, p-value, Cramér's V
explanationPlain-language narrative
# Independence test result <- easy_chisq(~ cyl + am, data = mtcars) print(result) # Goodness-of-fit result <- easy_chisq(~ cyl, data = mtcars) print(result)# Independence test result <- easy_chisq(~ cyl + am, data = mtcars) print(result) # Goodness-of-fit result <- easy_chisq(~ cyl, data = mtcars) print(result)
Computes bivariate or pairwise correlations (Pearson, Spearman, or Kendall) with significance tests and confidence intervals. For two variables a full narrative is generated; for multiple variables a correlation matrix is returned with a summary digest.
easy_correlation( x, y = NULL, data = NULL, vars = NULL, method = "pearson", conf_level = 0.95, alpha = 0.05 )easy_correlation( x, y = NULL, data = NULL, vars = NULL, method = "pearson", conf_level = 0.95, alpha = 0.05 )
x |
A numeric vector, a data frame, OR a formula |
y |
A numeric vector (paired with |
data |
A data frame. Required when |
vars |
Character vector of column names when |
method |
Correlation method: |
conf_level |
Confidence level for Pearson CI. Default |
alpha |
Significance threshold for narrative. Default |
An "easystat_result" object.
result <- easy_correlation(~ mpg + wt, data = mtcars) print(result) result <- easy_correlation(mtcars, vars = c("mpg", "hp", "wt", "disp")) print(result)result <- easy_correlation(~ mpg + wt, data = mtcars) print(result) result <- easy_correlation(mtcars, vars = c("mpg", "hp", "wt", "disp")) print(result)
Computes pairwise correlations and displays them as a color-coded heatmap, annotating each cell with the correlation coefficient and a significance star.
easy_correlation_heatmap(data, vars = NULL, method = "pearson", title = NULL)easy_correlation_heatmap(data, vars = NULL, method = "pearson", title = NULL)
data |
A data frame. |
vars |
Character vector of numeric column names. Default all numerics. |
method |
Correlation method: |
title |
Custom plot title. |
An "easystat_result" object with plot_object.
Draws a smooth kernel density estimate for a numeric variable. If a grouping variable is provided, separate overlapping density curves are drawn per group.
easy_density(x, data = NULL, group_by = NULL, fill_alpha = 0.35, title = NULL)easy_density(x, data = NULL, group_by = NULL, fill_alpha = 0.35, title = NULL)
x |
Column name or numeric vector. |
data |
A data frame. |
group_by |
Optional grouping column for multi-group densities. |
fill_alpha |
Alpha for filled area. Default |
title |
Custom plot title. |
An "easystat_result" object with plot_object.
Computes a rich set of descriptive statistics for one or more numeric variables, including measures of central tendency, dispersion, shape (skewness, kurtosis), and normality (Shapiro-Wilk), together with an automatic plain-language narrative interpretation.
easy_describe(data, vars = NULL, digits = 4, conf_level = 0.95)easy_describe(data, vars = NULL, digits = 4, conf_level = 0.95)
data |
A numeric vector or a data frame. |
vars |
Character vector of column names to describe when |
digits |
Number of decimal places in the summary table. Default |
conf_level |
Confidence level for the mean CI. Default |
An "easystat_result" object with:
coefficients_tableWide-format summary statistics table
model_fit_tableShape and normality digest
explanationPlain-language narrative (one per variable)
result <- easy_describe(mtcars, vars = c("mpg", "hp", "wt")) print(result)result <- easy_describe(mtcars, vars = c("mpg", "hp", "wt")) print(result)
Performs an F-test to compare the variances of two independent groups using
stats::var.test(), extracts the F-statistic, degrees of freedom,
p-value, variance ratio, and confidence interval, and generates a
plain-language narrative that includes a practical recommendation for
downstream t-test selection (equal vs. unequal variances).
easy_ftest( x, y = NULL, data = NULL, ratio = 1, alternative = "two.sided", conf_level = 0.95, alpha = 0.05 )easy_ftest( x, y = NULL, data = NULL, ratio = 1, alternative = "two.sided", conf_level = 0.95, alpha = 0.05 )
x |
A numeric vector (Group 1), OR a formula |
y |
A numeric vector (Group 2). Ignored when |
data |
A data frame. Required when |
ratio |
Hypothesized ratio of variances under H0. Default |
alternative |
|
conf_level |
Confidence level for the variance ratio CI. Default |
alpha |
Significance threshold for narrative. Default |
An "easystat_result" object.
result <- easy_ftest(mpg ~ am, data = mtcars) print(result)result <- easy_ftest(mpg ~ am, data = mtcars) print(result)
Computes descriptive statistics for a numeric outcome variable stratified by a grouping factor, providing both a comparison table and a narrative highlighting which group has the highest/lowest mean and variability.
easy_group_summary(formula, data, digits = 4)easy_group_summary(formula, data, digits = 4)
formula |
A formula of the form |
data |
A data frame containing the variables. |
digits |
Number of decimal places. Default |
An "easystat_result" object.
result <- easy_group_summary(mpg ~ cyl, data = mtcars) print(result)result <- easy_group_summary(mpg ~ cyl, data = mtcars) print(result)
Draws a histogram of a numeric variable, overlays a fitted normal density curve, and annotates the plot with the mean, median, and standard deviation. Normality is assessed via the Shapiro-Wilk test, and the result is displayed in the subtitle.
easy_histogram( x, data = NULL, bins = NULL, fill_color = NULL, show_normal = TRUE, title = NULL )easy_histogram( x, data = NULL, bins = NULL, fill_color = NULL, show_normal = TRUE, title = NULL )
x |
Character column name OR a numeric vector. |
data |
A data frame (required when |
bins |
Number of histogram bins. Default |
fill_color |
Bar fill color. Default EasyStat primary blue. |
show_normal |
Logical; overlay normal curve? Default |
title |
Custom plot title. Default auto-generated. |
An "easystat_result" object with plot_object.
Runs a Kruskal-Wallis rank-sum test for comparing three or more groups.
easy_kruskal(formula, data, alpha = 0.05)easy_kruskal(formula, data, alpha = 0.05)
formula |
A formula of the form |
data |
A data frame. |
alpha |
Significance threshold for narrative. Default |
An "easystat_result" object.
result <- easy_kruskal(Sepal.Length ~ Species, data = iris) print(result)result <- easy_kruskal(Sepal.Length ~ Species, data = iris) print(result)
Executes a binary logistic regression using stats::glm() with
family = binomial, extracts coefficients, odds ratios, approximate
confidence intervals, and model-fit metrics, then generates a plain-language
narrative via the Narrative Generator Module.
easy_logistic_regression(formula, data, alpha = 0.05, conf_level = 0.95)easy_logistic_regression(formula, data, alpha = 0.05, conf_level = 0.95)
formula |
A |
data |
A data frame containing the variables referenced in |
alpha |
Significance threshold used in narrative generation. Default |
conf_level |
Confidence level for odds-ratio intervals. Default |
An object of class "easystat_result" with coefficient, odds-ratio,
model-fit, raw glm, and narrative components.
result <- easy_logistic_regression(am ~ mpg + wt, data = mtcars) print(result)result <- easy_logistic_regression(am ~ mpg + wt, data = mtcars) print(result)
Creates a coefficient figure showing odds ratios and confidence intervals
for easy_logistic_regression results.
easy_odds_ratio_plot(result)easy_odds_ratio_plot(result)
result |
An |
An "easystat_result" object with plot_object.
Plots sample quantiles against theoretical normal quantiles and annotates the Shapiro-Wilk p-value. Deviations from the diagonal indicate non-normality.
easy_qqplot(x, data = NULL, title = NULL)easy_qqplot(x, data = NULL, title = NULL)
x |
Column name or numeric vector. |
data |
A data frame (required when |
title |
Custom plot title. |
An "easystat_result" object with plot_object.
Executes a standard OLS linear regression using stats::lm(), extracts
key metrics via the broom package, and automatically generates a
plain-language narrative explanation via the Narrative Generator Module.
easy_regression(formula, data, alpha = 0.05)easy_regression(formula, data, alpha = 0.05)
formula |
A |
data |
A data frame containing the variables referenced in |
alpha |
Significance threshold used in narrative generation. Default |
An object of class "easystat_result" (an R list) with:
test_typeCharacter: "regression"
formula_strCharacter string of the formula used
raw_modelThe raw lm object for advanced use
coefficients_tableTidy data frame of coefficients, SEs, t-stats, p-values
model_fit_tableData frame with R, Adjusted R, F-statistic, p-value
explanationPlain-language narrative string
result <- easy_regression(mpg ~ wt + hp, data = mtcars) print(result)result <- easy_regression(mpg ~ wt + hp, data = mtcars) print(result)
Creates a fitted-vs-residuals diagnostic figure for linear regression
results returned by easy_regression.
easy_regression_diagnostics(result)easy_regression_diagnostics(result)
result |
An |
An "easystat_result" object with plot_object.
Draws a scatter plot for two numeric variables, overlays a linear regression line with confidence band, and annotates the Pearson r and p-value.
easy_scatter( formula, data, color_by = NULL, smooth = TRUE, ellipse = TRUE, title = NULL )easy_scatter( formula, data, color_by = NULL, smooth = TRUE, ellipse = TRUE, title = NULL )
formula |
A formula: |
data |
A data frame. |
color_by |
Optional column name to color points by a third variable. |
smooth |
Logical; show regression line? Default |
ellipse |
Logical; draw a 95% data ellipse? Default |
title |
Custom plot title. |
An "easystat_result" object with plot_object.
Executes a two-sample (or one-sample) t-test using stats::t.test(),
extracts key metrics via broom, and generates a plain-language
narrative via the Narrative Generator Module.
easy_ttest( x, y = NULL, data = NULL, mu = 0, var.equal = FALSE, conf.level = 0.95, alpha = 0.05 )easy_ttest( x, y = NULL, data = NULL, mu = 0, var.equal = FALSE, conf.level = 0.95, alpha = 0.05 )
x |
A numeric vector, OR a formula of the form |
y |
A numeric vector (second group) when |
data |
A data frame. Required when |
mu |
Null hypothesis value for the mean (one-sample test). Default |
var.equal |
Logical; assume equal variances? Default |
conf.level |
Confidence level. Default |
alpha |
Significance threshold for narrative. Default |
An object of class "easystat_result" with:
test_typeCharacter: "ttest"
formula_strDescription of the comparison
raw_modelThe raw htest object
coefficients_tableGroup means and confidence interval
model_fit_tablet-statistic, df, and p-value
explanationPlain-language narrative string
result <- easy_ttest(mpg ~ am, data = mtcars) print(result)result <- easy_ttest(mpg ~ am, data = mtcars) print(result)
Runs a one-sample, paired, or two-sample Wilcoxon test using
stats::wilcox.test() and returns an "easystat_result" object.
easy_wilcox( x, y = NULL, data = NULL, mu = 0, paired = FALSE, alternative = "two.sided", conf_level = 0.95, alpha = 0.05 )easy_wilcox( x, y = NULL, data = NULL, mu = 0, paired = FALSE, alternative = "two.sided", conf_level = 0.95, alpha = 0.05 )
x |
Numeric vector, or a formula of the form |
y |
Optional numeric vector for paired or two-sample tests. |
data |
Data frame used when |
mu |
Null hypothesized location or location shift. Default |
paired |
Logical. Use paired test? Default |
alternative |
|
conf_level |
Confidence level. Default |
alpha |
Significance threshold for narrative. Default |
An "easystat_result" object.
result <- easy_wilcox(mpg ~ am, data = mtcars) print(result)result <- easy_wilcox(mpg ~ am, data = mtcars) print(result)
Performs a z-test using the normal distribution. When the population
standard deviation (sigma) is not provided, the sample SD is used
(valid for large samples, n 30, by the Central Limit Theorem).
Key metrics — z-statistic, p-value, confidence interval, and Cohen's d —
are extracted and fed to the Narrative Generator Module.
easy_ztest( x, y = NULL, data = NULL, mu = 0, sigma = NULL, sigma2 = NULL, alternative = "two.sided", conf_level = 0.95, alpha = 0.05 )easy_ztest( x, y = NULL, data = NULL, mu = 0, sigma = NULL, sigma2 = NULL, alternative = "two.sided", conf_level = 0.95, alpha = 0.05 )
x |
A numeric vector (Group 1), OR a formula |
y |
A numeric vector (Group 2) for a two-sample test. Ignored when
|
data |
A data frame. Required when |
mu |
Hypothesized population mean (one-sample) or mean difference
(two-sample). Default |
sigma |
Known population SD for Group 1 (or the single group).
If |
sigma2 |
Known population SD for Group 2. If |
alternative |
|
conf_level |
Confidence level. Default |
alpha |
Significance threshold for narrative. Default |
An "easystat_result" object.
# One-sample z-test (large n, CLT) result <- easy_ztest(mtcars$mpg, mu = 20) print(result) # Two-sample z-test via formula result <- easy_ztest(mpg ~ am, data = mtcars) print(result)# One-sample z-test (large n, CLT) result <- easy_ztest(mtcars$mpg, mu = 20) print(result) # Two-sample z-test via formula result <- easy_ztest(mpg ~ am, data = mtcars) print(result)
Takes a unified easystat_result object and writes a fully formatted
.docx report using the flextable and officer packages.
The report contains a title page header, the plain-language narrative,
both statistical tables rendered as professional flextable objects,
and a footer with metadata. All of this is produced in a single function call.
export_to_word(result, file, title = NULL, author = "EasyStat")export_to_word(result, file, title = NULL, author = "EasyStat")
result |
An object of class |
file |
Character string. Path to the output |
title |
Character string. Report title printed at the top of the
document. If |
author |
Character string. Author name(s) for the report header.
Default |
The file path invisibly (a length-one character vector). The
.docx file is written to the path supplied via file as a
side-effect.
result <- easy_regression(mpg ~ wt + hp, data = mtcars) export_to_word(result, file = tempfile(fileext = ".docx"), author = "Mr. Mahesh Divakaran")result <- easy_regression(mpg ~ wt + hp, data = mtcars) export_to_word(result, file = tempfile(fileext = ".docx"), author = "Mr. Mahesh Divakaran")
Automatically renders an easystat_result object. In an interactive
RStudio session the HTML Viewer is used; otherwise clean ASCII tables and
the plain-language narrative are written to the console.
## S3 method for class 'easystat_result' print(x, viewer = NULL, ...)## S3 method for class 'easystat_result' print(x, viewer = NULL, ...)
x |
An object of class |
viewer |
Logical. Force HTML Viewer output ( |
... |
Currently ignored. |
x invisibly.
Summarize an EasyStat Result Object
## S3 method for class 'easystat_result' summary(object, ...)## S3 method for class 'easystat_result' summary(object, ...)
object |
An |
... |
Passed to |
Called for its side effects (printing to the console or RStudio
Viewer). Returns object invisibly via
print.easystat_result.
Adds a clean, professional EasyStat visual theme to any ggplot2 object.
theme_easystat(base_size = 12, legend_position = "right")theme_easystat(base_size = 12, legend_position = "right")
base_size |
Base font size. Default |
legend_position |
Where to place the legend. Default |
A ggplot2::theme object.