Learn R Programming

ggstatsplot (version 0.10.0)

extract_stats: Extracting data frames or expressions from {ggstatsplot} plots

Description

Extracting data frames or expressions from {ggstatsplot} plots

Usage

extract_stats(p, ...)

extract_subtitle(p)

extract_caption(p)

Value

A list of tibbles containing summaries of various statistical analyses. The exact details included will depend on the function.

Arguments

p

A plot from {ggstatsplot} package

...

Ignored

Details

These are convenience functions to extract data frames or expressions with statistical details that are used to create expressions displayed in {ggstatsplot} plots as subtitle, caption, etc. Note that all of this analysis is carried out by the {statsExpressions} package. And so if you are using these functions only to extract data frames, you are better off using that package.

The only exception is the ggcorrmat() function. But, if a data frame is what you want, you shouldn't be using ggcorrmat() anyway. You can use correlation::correlation() function which provides tidy data frames by default.

Examples

Run this code
if (FALSE) { # requireNamespace("PMCMRplus", quietly = TRUE)
# \donttest{
set.seed(123)

# non-grouped function -----------------------------

p <- ggbetweenstats(mtcars, cyl, mpg)
extract_stats(p)

# the exact details depend on the function
ggbarstats(mtcars, cyl, am) %>% extract_stats()

# grouped function -----------------------------
p <- grouped_ggbarstats(
  Titanic_full,
  x = Survived,
  y = Sex,
  grouping.var = Age
)

extract_stats(p[[1L]])
extract_stats(p[[2L]])
# }
}

Run the code above in your browser using DataLab