% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/table_continuous.R
\name{table_continuous}
\alias{table_continuous}
\title{Continuous summary table}
\usage{
table_continuous(
  data,
  select = tidyselect::everything(),
  by = NULL,
  exclude = NULL,
  regex = FALSE,
  test = c("welch", "student", "nonparametric"),
  p_value = NULL,
  statistic = FALSE,
  effect_size = FALSE,
  effect_size_ci = FALSE,
  labels = NULL,
  ci_level = 0.95,
  digits = 2,
  effect_size_digits = 2,
  decimal_mark = ".",
  output = c("default", "data.frame", "tinytable", "gt", "flextable", "excel",
    "clipboard", "word"),
  excel_path = NULL,
  excel_sheet = "Descriptives",
  clipboard_delim = "\\t",
  word_path = NULL,
  verbose = FALSE
)
}
\arguments{
\item{data}{A \code{data.frame}.}

\item{select}{Columns to include. If \code{regex = FALSE}, use tidyselect
syntax or a character vector of column names (default:
\code{tidyselect::everything()}). If \code{regex = TRUE}, provide a regular
expression pattern (character string).}

\item{by}{Optional grouping column. Accepts an unquoted column name or
a single character column name. The column does not need to be
numeric.}

\item{exclude}{Columns to exclude. Supports tidyselect syntax and
character vectors of column names.}

\item{regex}{Logical. If \code{FALSE} (the default), uses tidyselect
helpers. If \code{TRUE}, the \code{select} argument is treated as a regular
expression.}

\item{test}{Character. Statistical test to use when comparing groups.
One of \code{"welch"} (default), \code{"student"}, or \code{"nonparametric"}.
\itemize{
\item \code{"welch"}: Welch \emph{t}-test (2 groups) or Welch one-way ANOVA
(3+ groups). Does not assume equal variances.
\item \code{"student"}: Student \emph{t}-test (2 groups) or classic one-way
ANOVA (3+ groups). Assumes equal variances.
\item \code{"nonparametric"}: Wilcoxon rank-sum / Mann--Whitney \emph{U}
(2 groups) or Kruskal--Wallis \emph{H} (3+ groups).
}

Used whenever \code{by} is supplied (since \code{p_value} defaults to \code{TRUE}
in that case) or when \code{statistic = TRUE} / \code{effect_size = TRUE}.
Ignored when \code{by} is not used, or when all three display toggles
are turned off.}

\item{p_value}{Logical or \code{NULL}. If \code{TRUE} and \code{by} is used, adds a
\emph{p}-value column from the test specified by \code{test}. When \code{NULL} (the
default), the \emph{p}-value is shown automatically whenever \code{by} is
supplied, and hidden otherwise. Pass \code{p_value = FALSE} to suppress
the column explicitly. Ignored when \code{by} is not used.}

\item{statistic}{Logical. If \code{TRUE} and \code{by} is used, the test
statistic is shown in an additional column (e.g.,
\code{t(df) = ...}, \code{F(df1, df2) = ...}, \code{W = ...}, or \code{H(df) = ...}).
Both \code{p_value} and \code{statistic} are independent; either or both
can be enabled. Defaults to \code{FALSE}. Ignored when \code{by} is not
used.}

\item{effect_size}{Logical. If \code{TRUE} and \code{by} is used, adds an
effect-size column ("ES"). The measure is chosen automatically:
\itemize{
\item Hedges' \emph{g} (bias-corrected) - 2 groups, parametric (CI via
Hedges & Olkin approximation).
\item Eta-squared (\eqn{\eta^2}) - 3+ groups, parametric (CI via
noncentral \emph{F} distribution).
\item Rank-biserial \emph{r} (\code{r_rb}) - 2 groups, nonparametric (CI via
Fisher \emph{z}-transform).
\item Epsilon-squared (\eqn{\varepsilon^2}) - 3+ groups,
nonparametric (CI via percentile bootstrap, 2 000 replicates).
}

Defaults to \code{FALSE}. Ignored when \code{by} is not used.}

\item{effect_size_ci}{Logical. If \code{TRUE}, appends the confidence
interval of the effect size in brackets (e.g.,
\code{g = 0.45 [0.22, 0.68]}). Implies \code{effect_size = TRUE}.
Defaults to \code{FALSE}.}

\item{labels}{An optional named character vector of variable labels.
Names must match column names in \code{data}. When \code{NULL} (the default),
labels are auto-detected from variable attributes (e.g., haven
labels); if none are found, the column name is used.}

\item{ci_level}{Confidence level for the mean confidence interval
(default: \code{0.95}). Must be between 0 and 1 exclusive.}

\item{digits}{Number of decimal places for descriptive values and test
statistics (default: \code{2}).}

\item{effect_size_digits}{Number of decimal places for effect-size values
in formatted displays (default: \code{2}).}

\item{decimal_mark}{Character used as decimal separator.
Either \code{"."} (default) or \code{","}.}

\item{output}{Output format. One of:
\itemize{
\item \code{"default"} (a printed ASCII table, returned invisibly)
\item \code{"data.frame"} (a plain numeric \code{data.frame})
\item \code{"tinytable"} (requires \code{tinytable})
\item \code{"gt"} (requires \code{gt})
\item \code{"flextable"} (requires \code{flextable})
\item \code{"excel"} (requires \code{openxlsx2})
\item \code{"clipboard"} (requires \code{clipr})
\item \code{"word"} (requires \code{flextable} and \code{officer})
}}

\item{excel_path}{File path for \code{output = "excel"}.}

\item{excel_sheet}{Sheet name for \code{output = "excel"}
(default: \code{"Descriptives"}).}

\item{clipboard_delim}{Delimiter for \code{output = "clipboard"}
(default: \code{"\\t"}).}

\item{word_path}{File path for \code{output = "word"}.}

\item{verbose}{Logical. If \code{TRUE}, prints messages about excluded
non-numeric columns (default: \code{FALSE}).}
}
\value{
Depends on \code{output}:
\itemize{
\item \code{"default"}: prints a styled ASCII table and returns the
underlying \code{data.frame} invisibly (S3 class
\code{"spicy_continuous_table"}).
\item \code{"data.frame"}: a plain \code{data.frame} with columns
\code{variable}, \code{label}, \code{group} (when \code{by} is used), \code{mean}, \code{sd},
\code{min}, \code{max}, \code{ci_lower}, \code{ci_upper}, \code{n}.
When \code{by} is used together with \code{p_value = TRUE},
\code{statistic = TRUE}, or \code{effect_size = TRUE}, additional columns
are appended (populated on the first row of each variable block
only):
\itemize{
\item \code{test_type} -- test identifier (e.g., \code{"welch_t"},
\code{"welch_anova"}, \code{"student_t"}, \code{"anova"}, \code{"wilcoxon"},
\code{"kruskal"}).
\item \code{statistic}, \code{df1}, \code{df2}, \code{p.value} -- test results.
\item \code{es_type} -- effect-size identifier (\code{"hedges_g"},
\code{"eta_sq"}, \code{"r_rb"}, or \code{"epsilon_sq"}), when
\code{effect_size = TRUE}.
\item \code{es_value}, \code{es_ci_lower}, \code{es_ci_upper} -- effect-size
estimate and confidence interval bounds.
}
\item \code{"tinytable"}: a \code{tinytable} object.
\item \code{"gt"}: a \code{gt_tbl} object.
\item \code{"flextable"}: a \code{flextable} object.
\item \code{"excel"} / \code{"word"}: writes to disk and returns the file
path invisibly.
\item \code{"clipboard"}: copies the table and returns the display
\code{data.frame} invisibly.
}
}
\description{
Computes descriptive statistics (mean, SD, min, max, confidence interval
of the mean, \emph{n}) for one or many continuous variables selected with
tidyselect syntax.

With \code{by}, produces grouped summaries and reports a group-comparison
\emph{p}-value by default (Welch test; change via \code{test}). Additional
inferential output is opt-in: test statistics (\code{statistic}) and
effect sizes (\code{effect_size} / \code{effect_size_ci}). Set \code{p_value = FALSE}
to suppress the \emph{p}-value column. Without \code{by}, produces one-way
descriptive summaries.

Multiple output formats are available via \code{output}: a printed ASCII
table (\code{"default"}), a plain numeric \code{data.frame} (\code{"data.frame"}), or
publication-ready tables (\code{"tinytable"}, \code{"gt"}, \code{"flextable"},
\code{"excel"}, \code{"clipboard"}, \code{"word"}).
}
\details{
Non-numeric columns are silently dropped (set \code{verbose = TRUE} to see
which columns were excluded). When a single constant column is passed,
SD and CI are shown as \code{"--"} in the ASCII table.

Optional output engines require suggested packages:
\itemize{
\item \pkg{tinytable} for \code{output = "tinytable"}
\item \pkg{gt} for \code{output = "gt"}
\item \pkg{flextable} for \code{output = "flextable"}
\item \pkg{flextable} + \pkg{officer} for \code{output = "word"}
\item \pkg{openxlsx2} for \code{output = "excel"}
\item \pkg{clipr} for \code{output = "clipboard"}
}
}
\examples{
table_continuous(
  sochealth,
  select = c(bmi, wellbeing_score)
)

table_continuous(
  sochealth,
  select = c(bmi, wellbeing_score),
  output = "data.frame"
)

table_continuous(
  sochealth,
  select = c(bmi, wellbeing_score),
  by = education
)

table_continuous(
  sochealth,
  select = c(bmi, wellbeing_score),
  by = education,
  statistic = TRUE
)

table_continuous(
  sochealth,
  select = wellbeing_score,
  by = education,
  effect_size_ci = TRUE,
  effect_size_digits = 3
)

table_continuous(
  sochealth,
  select = wellbeing_score,
  by = sex,
  effect_size_ci = TRUE
)

table_continuous(
  sochealth,
  select = "^life_sat",
  regex = TRUE
)

table_continuous(
  sochealth,
  select = c(bmi, life_sat_health),
  labels = c(
    bmi = "Body mass index",
    life_sat_health = "Satisfaction with health"
  )
)

\donttest{
if (requireNamespace("tinytable", quietly = TRUE)) {
  table_continuous(
    sochealth,
    select = starts_with("life_sat"),
    by = education,
    output = "tinytable"
  )
}

if (requireNamespace("gt", quietly = TRUE)) {
  table_continuous(
    sochealth,
    select = starts_with("life_sat"),
    by = education,
    output = "gt"
  )
}

if (requireNamespace("flextable", quietly = TRUE)) {
  table_continuous(
    sochealth,
    select = starts_with("life_sat"),
    by = education,
    output = "flextable"
  )
}
}

}
\seealso{
\code{\link[=table_categorical]{table_categorical()}} for categorical variables;
\code{\link[=freq]{freq()}} for one-way frequency tables; \code{\link[=cross_tab]{cross_tab()}} for two-way
cross-tabulations.
}
