% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get_summary_stats.R
\name{get_summary_stats}
\alias{get_summary_stats}
\title{Compute Summary Statistics}
\usage{
get_summary_stats(
  data,
  ...,
  type = c("full", "common", "robust", "five_number", "mean_sd", "mean_se", "mean_ci",
    "median_iqr", "median_mad", "quantile", "mean", "median", "min", "max"),
  show = NULL,
  probs = seq(0, 1, 0.25),
  digits = 3
)
}
\arguments{
\item{data}{a data frame}

\item{...}{(optional) One or more unquoted expressions (or variable names)
separated by commas. Used to select a variable of interest. If no variable
is specified, then the summary statistics of all numeric variables in the
data frame is computed.}

\item{type}{type of summary statistics. Possible values include: \code{"full",
"common", "robust",  "five_number", "mean_sd", "mean_se", "mean_ci",
"median_iqr", "median_mad", "quantile", "mean", "median",  "min", "max"}}

\item{show}{a character vector specifying the summary statistics you want to
show. Example: \code{show = c("n", "mean", "sd")}. This is used to filter
the output after computation. It can additionally include \code{"skewness"}
and/or \code{"kurtosis"} (e.g. \code{show = c("mean", "sd", "skewness",
"kurtosis")}); these two are computed on demand and are not part of any
default \code{type}.}

\item{probs}{numeric vector of probabilities with values in [0,1]. Used only when type = "quantile".}

\item{digits}{integer indicating the number of decimal places to round the
summary statistics to. Default is 3. Increase it when summarizing very small
values that would otherwise round to 0.}
}
\value{
A data frame containing descriptive statistics, such as: \itemize{
 \item \strong{n}: the number of individuals \item \strong{min}: minimum
 \item \strong{max}: maximum \item \strong{median}: median \item
 \strong{mean}: mean \item \strong{q1, q3}: the first and the third quartile,
 respectively. \item \strong{iqr}: interquartile range \item \strong{mad}:
 median absolute deviation (see ?MAD) \item \strong{sd}: standard deviation
 of the mean \item \strong{se}: standard error of the mean \item \strong{ci}: 95 percent confidence interval of the mean }

 When requested through \code{show}, the output can also contain: \itemize{
 \item \strong{skewness}: bias-corrected sample skewness \item
 \strong{kurtosis}: bias-corrected sample excess kurtosis (0 for a normal
 distribution). } Both use the type-2 (bias-corrected) estimator, matching
 \code{e1071} with \code{type = 2}:
 skewness \eqn{= g_1\sqrt{n(n-1)}/(n-2)} and kurtosis \eqn{= [(n+1)g_2 + 6]
 (n-1)/[(n-2)(n-3)]}, where \eqn{g_1 = m_3/m_2^{1.5}} and \eqn{g_2 =
 m_4/m_2^2 - 3}. Skewness is \code{NA} for n < 3 and kurtosis for n < 4.
}
\description{
Compute summary statistics for one or multiple numeric variables.
}
\examples{
# Full summary statistics
data("ToothGrowth")
ToothGrowth \%>\% get_summary_stats(len)

# Summary statistics of grouped data
# Show only common summary
ToothGrowth \%>\%
  group_by(dose, supp) \%>\%
  get_summary_stats(len, type = "common")

# Robust summary statistics
ToothGrowth \%>\% get_summary_stats(len, type = "robust")

# Five number summary statistics
ToothGrowth \%>\% get_summary_stats(len, type = "five_number")

# Compute only mean and sd
ToothGrowth \%>\% get_summary_stats(len, type = "mean_sd")

# Compute full summary statistics but show only mean, sd, median, iqr
ToothGrowth \%>\%
    get_summary_stats(len, show = c("mean", "sd", "median", "iqr"))

# Include skewness and kurtosis (computed on demand via show)
ToothGrowth \%>\%
    get_summary_stats(len, show = c("mean", "sd", "skewness", "kurtosis"))

}
\seealso{
\code{\link{rstatix-programming}} for selecting columns by names held
 in strings (\code{!!}, \code{\{\{ \}\}}, \code{vars=}, \code{all_of()}).
}
