'Wrapper Function for ggstatsplot::gghistostats and ggstatsplot::grouped_gghistostats to generate Histogram.'
Usage
jjhistostats(
data,
dep,
grvar,
typestatistics = "parametric",
centralityline = TRUE,
changebinwidth = FALSE,
binwidth = 1.1,
resultssubtitle = TRUE,
test.value = 0,
conf.level = 0.95,
bf.message = TRUE,
digits = 2,
xlab = "",
title = "",
subtitle = "",
caption = "",
centralitytype = "default",
binfill = "skyblue",
bincolor = "black",
binalpha = 0.7,
centralitylinecolor = "blue",
centralitylinewidth = 1,
centralitylinetype = "dashed"
)
Arguments
- data
The data as a data frame.
- dep
One or more continuous numeric variables for which histograms will be created. Multiple variables will be displayed in separate panels.
- grvar
Optional grouping variable to create separate histograms for each level of this variable (grouped analysis).
- typestatistics
Type of statistical test for normality assessment. 'parametric' uses Shapiro-Wilk test, 'nonparametric' uses Anderson-Darling test, 'robust' uses robust normality tests, 'bayes' provides Bayesian analysis.
- centralityline
Whether to display a vertical line indicating the measure of central tendency (mean for parametric, median for nonparametric).
- changebinwidth
Whether to manually specify the bin width. If FALSE, automatic bin width calculation will be used.
- binwidth
Manual bin width for histogram. Only used when changebinwidth is TRUE. Smaller values create more bins, larger values create fewer bins.
- resultssubtitle
Whether to display statistical test results as subtitle in the plot, including normality test results and descriptive statistics.
- test.value
Value to compare the sample against in one-sample test. Default is 0.
- conf.level
Confidence level for confidence intervals (between 0 and 1).
- bf.message
Whether to display Bayes Factor in the subtitle when using Bayesian analysis.
- digits
Number of decimal places for displaying statistics in the subtitle.
- xlab
Custom label for the x-axis. If empty, variable name will be used.
- title
Title for the plot.
- subtitle
Subtitle for the plot (overrides statistical results if provided).
- caption
Caption text to display at the bottom of the plot.
- centralitytype
Type of central tendency measure to display. 'Default' uses the appropriate measure based on the statistical test type selected.
- binfill
Fill color for histogram bins.
- bincolor
Border color for histogram bins.
- binalpha
Transparency level for histogram bins (0 = fully transparent, 1 = opaque).
- centralitylinecolor
Color of the vertical centrality line.
- centralitylinewidth
Width of the vertical centrality line.
- centralitylinetype
Line type for the vertical centrality line.
Examples
# \donttest{
# Load test data
data(jjhistostats_test_data)
#> Warning: data set ‘jjhistostats_test_data’ not found
# Basic histogram
jjhistostats(
data = jjhistostats_test_data,
dep = "age_years",
typestatistics = "parametric"
)
#> Error in jjhistostats(data = jjhistostats_test_data, dep = "age_years", typestatistics = "parametric"): argument "grvar" is missing, with no default
# Multiple histograms
jjhistostats(
data = jjhistostats_test_data,
dep = c("age_years", "tumor_size_mm", "bmi"),
centralityline = TRUE,
resultssubtitle = TRUE
)
#> Error in jjhistostats(data = jjhistostats_test_data, dep = c("age_years", "tumor_size_mm", "bmi"), centralityline = TRUE, resultssubtitle = TRUE): argument "grvar" is missing, with no default
# Grouped histogram by disease stage
jjhistostats(
data = jjhistostats_test_data,
dep = "psa_level",
grvar = "disease_stage",
typestatistics = "nonparametric",
changebinwidth = TRUE,
binwidth = 2.0
)
#> Error: object 'jjhistostats_test_data' not found
# }