| Title: | Publication-Ready Formatting for Statistical Results |
| Version: | 0.2.0 |
| Description: | Provides tools for converting already-computed statistical results into consistent, publication-ready character output. Supports p-values, confidence intervals, correlation coefficients, percentages, test statistics, and commonly reported effect sizes, with optional confidence intervals and multiple output styles for selected statistical symbols. The package emphasizes separation of statistical calculation, interpretation, and publication formatting so that reporting choices do not alter the underlying numeric results or inferential decisions. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| Config/roxygen2/version: | 8.1.0 |
| URL: | https://github.com/Reynolds826/pubformat |
| BugReports: | https://github.com/Reynolds826/pubformat/issues |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2026-10-29 18:39:37 UTC; rballotti |
| Author: | RJ Ballotti [aut, cre] |
| Maintainer: | RJ Ballotti <rballotti@coastal.edu> |
| Repository: | CRAN |
| Date/Publication: | 2026-10-29 20:40:09 UTC |
Format confidence intervals for publication
Description
Formats lower and upper confidence interval limits using publication-friendly conventions. By default, confidence intervals are displayed using APA-style square brackets.
Usage
format_ci(
lower,
upper,
level = 0.95,
digits = 2,
prefix = TRUE,
leading_zero = TRUE
)
Arguments
lower |
Numeric vector containing lower confidence limits. |
upper |
Numeric vector containing upper confidence limits. |
level |
A single numeric value between 0 and 1 specifying the confidence level. Default is 0.95. |
digits |
A single non-negative integer specifying the number of decimal places to display. Default is 2. |
prefix |
Logical. If TRUE, the confidence level and |
leading_zero |
Logical. If TRUE, values between -1 and 1 retain a leading zero. Default is TRUE. |
Details
Confidence intervals are formatted using square brackets with the lower and upper limits separated by a comma.
The function does not infer the type of statistic being reported.
For statistics that cannot exceed 1 in absolute value, such as
correlations, leading_zero = FALSE can be used.
Value
A character vector containing formatted confidence intervals.
Examples
format_ci(1.08, 1.87)
format_ci(-0.42, 0.18)
format_ci(0.21, 0.48, leading_zero = FALSE)
format_ci(c(1.08, 2.15), c(1.87, 3.02))
Format correlation coefficients for publication
Description
Formats Pearson, Spearman, and Kendall correlation coefficients using publication-friendly conventions. The appropriate statistical symbol is selected automatically from the requested correlation method.
Usage
format_cor(
r,
method = "pearson",
digits = 2,
prefix = TRUE,
leading_zero = FALSE
)
Arguments
r |
Numeric vector containing correlation coefficients. Values must be between -1 and 1. |
method |
Character string specifying the correlation method.
Must be one of |
digits |
A single non-negative integer specifying the number of decimal places to display. Default is 2. |
prefix |
Logical. If TRUE, the method-appropriate statistical symbol and equals sign are included. Default is TRUE. |
leading_zero |
Logical. If FALSE, leading zeros are omitted for values between -1 and 1. Default is FALSE. |
Details
format_cor() supports three correlation methods:
Pearson:
rSpearman: rho
Kendall: tau
The function formats correlation coefficients only. It does not calculate correlations, determine statistical significance, or format associated p-values.
Missing values are returned as NA.
Value
A character vector containing formatted correlation coefficients.
Examples
format_cor(0.42)
format_cor(0.42, method = "pearson")
format_cor(0.42, method = "spearman")
format_cor(0.42, method = "kendall")
format_cor(c(0.42, -0.31, 0), method = "spearman")
Format Cohen's d
Description
Formats an already-computed Cohen's d effect size as publication-ready text. An optional confidence interval can be supplied using numeric lower and upper limits.
Usage
format_d(
d,
lower = NULL,
upper = NULL,
level = 0.95,
digits = 2,
ci_digits = 2,
style = c("plain", "markdown", "html", "latex")
)
Arguments
d |
Numeric vector of Cohen's d effect sizes. |
lower |
Optional numeric vector of lower confidence limits. |
upper |
Optional numeric vector of upper confidence limits. |
level |
Confidence level used when a confidence interval is supplied. Defaults to 0.95. |
digits |
Number of decimal places used for Cohen's d. |
ci_digits |
Number of decimal places used for confidence limits. |
style |
Output style. One of |
Details
format_d() does not calculate Cohen's d or interpret the magnitude
of the effect. It formats an already-computed numeric result.
Value
A character vector containing formatted Cohen's d values.
Examples
format_d(0.52)
format_d(
0.52,
lower = 0.18,
upper = 0.86
)
format_d(
0.52,
lower = 0.18,
upper = 0.86,
style = "markdown"
)
Format Eta Squared
Description
Formats an already-computed eta-squared effect size as publication-ready text. An optional confidence interval can be supplied using numeric lower and upper limits.
Usage
format_eta2(
eta2,
lower = NULL,
upper = NULL,
level = 0.95,
digits = 2,
ci_digits = 2
)
Arguments
eta2 |
Numeric vector of eta-squared effect sizes. |
lower |
Optional numeric vector of lower confidence limits. |
upper |
Optional numeric vector of upper confidence limits. |
level |
Confidence level used when a confidence interval is supplied. Defaults to 0.95. |
digits |
Number of decimal places used for eta squared. |
ci_digits |
Number of decimal places used for confidence limits. |
Details
format_eta2() does not calculate eta squared or interpret the
magnitude of the effect. It formats an already-computed numeric
result.
Value
A character vector containing formatted eta-squared values.
Examples
format_eta2(0.14)
format_eta2(
0.14,
lower = 0.08,
upper = 0.21
)
Format an F Test Statistic
Description
Formats an already-computed F statistic and its numerator and
denominator degrees of freedom as publication-ready text. An
optional p-value can be supplied and is formatted using format_p().
Usage
format_f(
statistic,
df1,
df2,
p = NULL,
digits = 2,
df_digits = 2,
p_digits = 3,
p_threshold = NULL,
p_sig = FALSE,
style = c("plain", "markdown", "html", "latex")
)
Arguments
statistic |
Numeric vector of F statistics. |
df1 |
Numeric vector of numerator degrees of freedom. |
df2 |
Numeric vector of denominator degrees of freedom. |
p |
Optional numeric vector of p-values. |
digits |
Number of decimal places used for the F statistic. |
df_digits |
Maximum number of decimal places used for non-integer degrees of freedom. Trailing zeros are removed. |
p_digits |
Number of decimal places passed to |
p_threshold |
Optional reporting threshold passed to |
p_sig |
Logical. Whether significance codes should be appended to the p-value. |
style |
Output style. One of |
Value
A character vector containing formatted F-test results.
Examples
format_f(2.50, df1 = 2, df2 = 30)
format_f(4.4344, df1 = 1, df2 = 3262.9, p = 0.03530)
format_f(
4.4344,
df1 = 1,
df2 = 3262.9,
p = 0.03530,
style = "markdown"
)
Format Hedges' g
Description
Formats an already-computed Hedges' g effect size as publication-ready text. An optional confidence interval can be supplied using numeric lower and upper limits.
Usage
format_g(
g,
lower = NULL,
upper = NULL,
level = 0.95,
digits = 2,
ci_digits = 2,
style = c("plain", "markdown", "html", "latex")
)
Arguments
g |
Numeric vector of Hedges' g effect sizes. |
lower |
Optional numeric vector of lower confidence limits. |
upper |
Optional numeric vector of upper confidence limits. |
level |
Confidence level used when a confidence interval is supplied. Defaults to 0.95. |
digits |
Number of decimal places used for Hedges' g. |
ci_digits |
Number of decimal places used for confidence limits. |
style |
Output style. One of |
Details
format_g() does not calculate Hedges' g or interpret the magnitude
of the effect. It formats an already-computed numeric result.
Value
A character vector containing formatted Hedges' g values.
Examples
format_g(0.49)
format_g(
0.49,
lower = 0.16,
upper = 0.82
)
format_g(
0.49,
lower = 0.16,
upper = 0.82,
style = "markdown"
)
Format Omega Squared
Description
Formats an already-computed omega-squared effect size as publication-ready text. An optional confidence interval can be supplied using numeric lower and upper limits.
Usage
format_omega2(
omega2,
lower = NULL,
upper = NULL,
level = 0.95,
digits = 2,
ci_digits = 2
)
Arguments
omega2 |
Numeric vector of omega-squared effect sizes. Negative estimates are permitted. Values greater than 1 are not. |
lower |
Optional numeric vector of lower confidence limits. |
upper |
Optional numeric vector of upper confidence limits. |
level |
Confidence level used when a confidence interval is supplied. Defaults to 0.95. |
digits |
Number of decimal places used for omega squared. |
ci_digits |
Number of decimal places used for confidence limits. |
Details
format_omega2() does not calculate omega squared or interpret the
magnitude of the effect. Negative estimates are preserved rather than
automatically truncated to zero.
Value
A character vector containing formatted omega-squared values.
Examples
format_omega2(0.08)
format_omega2(-0.02)
format_omega2(
0.08,
lower = 0.02,
upper = 0.15
)
Format p-values for publication
Description
Formats numeric p-values using publication-friendly conventions. Values are displayed with a fixed number of decimal places, leading zeros are omitted, and very small p-values are reported using less-than notation.
Usage
format_p(pval, digits = 3, threshold = NULL, sig = FALSE, prefix = TRUE)
Arguments
pval |
Numeric vector containing p-values. |
digits |
A single non-negative integer specifying the number of decimal places to display. Default is 3. |
threshold |
Optional numeric reporting threshold. Values strictly below this threshold are displayed using less-than notation. If NULL (the default), the threshold is automatically set to 10^-digits. For example, digits = 3 produces a threshold of .001. |
sig |
Logical. If TRUE, conventional significance codes are appended. Default is FALSE. |
prefix |
Logical. If TRUE, "p" is included before the formatted value. Default is TRUE. |
Details
The reporting threshold controls only how a p-value is displayed. It does not represent an alpha level or statistical decision rule.
With digits = 3:
p = .001 is reported as "p = .001" p = .0009 is reported as "p < .001"
Significance codes use the conventional strict thresholds:
*** p < .001 ** p < .01
p < .05 . p < .10 ns otherwise
Value
A character vector containing formatted p-values.
Examples
format_p(0.048)
format_p(0.0002)
format_p(0.001)
format_p(0.048, sig = TRUE)
format_p(c(0.048, 0.006, 0.0002, 0.213))
Format Partial Eta Squared
Description
Formats an already-computed partial eta-squared effect size as publication-ready text. An optional confidence interval can be supplied using numeric lower and upper limits.
Usage
format_partial_eta2(
eta2p,
lower = NULL,
upper = NULL,
level = 0.95,
digits = 2,
ci_digits = 2
)
Arguments
eta2p |
Numeric vector of partial eta-squared effect sizes. |
lower |
Optional numeric vector of lower confidence limits. |
upper |
Optional numeric vector of upper confidence limits. |
level |
Confidence level used when a confidence interval is supplied. Defaults to 0.95. |
digits |
Number of decimal places used for partial eta squared. |
ci_digits |
Number of decimal places used for confidence limits. |
Details
format_partial_eta2() does not calculate partial eta squared or
interpret the magnitude of the effect. It formats an already-computed
numeric result.
Value
A character vector containing formatted partial eta-squared values.
Examples
format_partial_eta2(0.14)
format_partial_eta2(
0.14,
lower = 0.08,
upper = 0.21
)
Format percentages for publication
Description
Formats proportions or percentages using publication-friendly conventions. By default, input values are interpreted as proportions and converted to percentages.
Usage
format_percent(x, digits = 1, input = "proportion", symbol = TRUE)
Arguments
x |
Numeric vector containing proportions or percentages. |
digits |
A single non-negative integer specifying the number of decimal places to display. Default is 1. |
input |
Character string specifying how |
symbol |
Logical. If TRUE, the percent symbol is appended to each value. Default is TRUE. |
Details
When input = "proportion", values must fall between 0 and 1
and are multiplied by 100 before formatting.
When input = "percent", values are assumed to already be expressed
as percentages and are not rescaled.
Missing values are returned as NA.
Value
A character vector containing formatted percentages.
Examples
format_percent(0.42)
format_percent(0.423, digits = 2)
format_percent(42, input = "percent")
format_percent(c(0.25, 0.50, 0.75))
Format correlation coefficients for publication
Description
Formats correlation coefficients using publication-friendly conventions. By default, values are displayed with two decimal places and leading zeros are omitted, consistent with common APA-style reporting for statistics that cannot exceed 1 in absolute value.
Usage
format_r(r, digits = 2, prefix = TRUE, leading_zero = FALSE)
Arguments
r |
Numeric vector containing correlation coefficients. Values must be between -1 and 1. |
digits |
A single non-negative integer specifying the number of decimal places to display. Default is 2. |
prefix |
Logical. If TRUE, |
leading_zero |
Logical. If FALSE, leading zeros are omitted for values between -1 and 1. Default is FALSE. |
Details
format_r() formats correlation coefficients only. It does not
determine statistical significance or format associated p-values.
Missing values are returned as NA.
Value
A character vector containing formatted correlation coefficients.
Examples
format_r(0.42)
format_r(-0.31)
format_r(c(0.42, -0.31, 0))
format_r(0.42, leading_zero = TRUE)
Format a t Test Statistic
Description
Formats an already-computed t statistic and its degrees of freedom
as publication-ready text. An optional p-value can be supplied and
is formatted using format_p().
Usage
format_t(
statistic,
df,
p = NULL,
digits = 2,
df_digits = 2,
p_digits = 3,
p_threshold = NULL,
p_sig = FALSE,
style = c("plain", "markdown", "html", "latex")
)
Arguments
statistic |
Numeric vector of t statistics. |
df |
Numeric vector of degrees of freedom. |
p |
Optional numeric vector of p-values. |
digits |
Number of decimal places used for the t statistic. |
df_digits |
Maximum number of decimal places used for non-integer degrees of freedom. Trailing zeros are removed. |
p_digits |
Number of decimal places passed to |
p_threshold |
Optional reporting threshold passed to |
p_sig |
Logical. Whether significance codes should be appended to the p-value. |
style |
Output style. One of |
Value
A character vector containing formatted t-test results.
Examples
format_t(0.86, df = 20)
format_t(0.86, df = 20, p = 0.041)
format_t(0.86, df = 20, p = 0.041, style = "markdown")