% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/p_format_utils.R
\name{format_p_value}
\alias{format_p_value}
\title{Format P-Values According to Style or Custom Settings}
\usage{
format_p_value(
  p,
  style = "default",
  digits = NULL,
  leading.zero = NULL,
  min.threshold = NULL,
  decimal.mark = NULL,
  use.scientific = NULL
)
}
\arguments{
\item{p}{Numeric vector of p-values to format.}

\item{style}{Character string specifying the formatting style. One of:
\itemize{
  \item \code{"default"}: Current behavior with scientific notation (backward compatible)
  \item \code{"apa"}: APA Style - no leading zero, 3 decimals, "< .001" threshold
  \item \code{"nejm"}: NEJM Style - leading zero, 3 decimals, "< 0.001" threshold
  \item \code{"lancet"}: Lancet Style - leading zero, 4 decimals, "< 0.0001" threshold
  \item \code{"ama"}: AMA Style - no leading zero, 3 decimals, "< .001" threshold
  \item \code{"graphpad"}: GraphPad Style - leading zero, 4 decimals, "< 0.0001" threshold
  \item \code{"scientific"}: Scientific notation for genomics/GWAS studies
}}

\item{digits}{Integer specifying the number of decimal places. If provided,
overrides the style default.}

\item{leading.zero}{Logical indicating whether to include leading zero before
decimal point (e.g., "0.05" vs ".05"). If provided, overrides the style default.}

\item{min.threshold}{Numeric specifying the minimum p-value to display exactly.
Values below this threshold are shown as "< threshold" (e.g., "< 0.001").
If NULL, the selected style's default threshold is used; styles without a
threshold show exact values. If provided, overrides the style default.
Must be a single positive finite number.}

\item{decimal.mark}{Character string to use as the decimal mark. If NULL,
uses \code{getOption("OutDec")}.}

\item{use.scientific}{Logical indicating whether to force scientific notation.
If NULL, uses the style default.}
}
\value{
Character vector of formatted p-values.
}
\description{
Formats p-values according to major scientific publication standards
  (APA, AMA, NEJM, Lancet, etc.) or custom user-defined settings. This function
  provides flexible control over decimal places, leading zeros, and threshold
  notation for very small p-values.
}
\details{
P-value formatting conventions vary across scientific disciplines and journals:

\strong{APA Style} (Psychology, Social Sciences):
\itemize{
  \item No leading zero (write ".05" not "0.05")
  \item 3 decimal places
  \item Report as "p < .001" for very small values
}

\strong{NEJM/Medical Journals}:
\itemize{
  \item Leading zero (write "0.05" not ".05")
  \item 3 decimal places
  \item P < 0.001: report as "< 0.001"
}

\strong{Scientific Notation} (GWAS, Genomics):
\itemize{
  \item Used when very small p-values are meaningful (e.g., 5e-8 threshold)
  \item Appropriate for high-dimensional data analyses
}
}
\examples{
# Test p-values
p_vals <- c(0.76404, 0.0432, 0.0043, 0.00018, 1.7e-11)

# Different styles
format_p_value(p_vals, style = "default")
format_p_value(p_vals, style = "apa")
format_p_value(p_vals, style = "nejm")
format_p_value(p_vals, style = "lancet")

# Custom formatting
format_p_value(p_vals, digits = 2, leading.zero = FALSE, min.threshold = 0.01)

# Override style defaults
format_p_value(p_vals, style = "nejm", digits = 4)

}
\seealso{
\code{\link{get_p_format_style}}, \code{\link{list_p_format_styles}}
}
