View source: R/extract-stats.R
| extract_stats | R Documentation |
{ggstatsplot} plotsExtracting data frames or expressions from {ggstatsplot} plots
extract_stats(p)
extract_subtitle(p)
extract_caption(p)
p |
A plot from |
These helpers retrieve the statistical data frames and expressions retained
by {ggstatsplot} plots. If you only need tabular results, call the
underlying analysis functions directly: {statsExpressions} for statistical
tests, parameters::model_parameters() for model coefficients, and
performance::model_performance() for model fit indices.
ggcorrmat() does not retain statistical data frames, so all elements
returned by extract_stats() are NULL. Use
correlation::correlation() to obtain its statistical results as data.
For extract_stats(), a list with the following elements, each either a
data frame or NULL if not relevant for the given plot:
subtitle_data: results of the test displayed in the subtitle
caption_data: results of the test displayed in the caption (typically,
the Bayesian test)
pairwise_comparisons_data: results of pairwise comparisons
descriptive_data: counts and percentages (ggpiestats() and
ggbarstats())
one_sample_data: proportion tests for each level of y
(ggpiestats() and ggbarstats())
tidy_data: tidy model parameters (ggcoefstats())
glance_data: model performance indices (ggcoefstats())
For extract_subtitle() and extract_caption(), the statistical expression
used in the subtitle or caption, respectively (or NULL if unavailable).
User-supplied subtitle and caption text is not returned.
For plots from grouped_* functions, a list with one such element per plot.
set.seed(123)
# non-grouped plot
p1 <- ggbetweenstats(mtcars, cyl, mpg)
# grouped plot
p2 <- grouped_ggbarstats(Titanic_full, Survived, Sex, grouping.var = Age)
# extracting expressions -----------------------------
extract_subtitle(p1)
extract_caption(p1)
extract_subtitle(p2)
extract_caption(p2)
# extracting data frames -----------------------------
extract_stats(p1)
extract_stats(p2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.