format_stat: Format statistics appropriately

View source: R/formatting.R

format_statR Documentation

Format statistics appropriately

Description

This formats numbers according to APA.

Usage

format_stat(
  x,
  digits = 2,
  type = c("default", "p", "quotient"),
  sign.positive = FALSE
)

Arguments

x

A numeric vector.

digits

How many digits to round the number to.

type

Type of statistic formatting rule to apply. "p" prints values rounded to zero as <.001, and "quotient" prints values <1 as 1/x where x is a value above 1 (e.g. in case of Bayes factors).

sign.positive

If TRUE, adds a + to every positive number.

Details

All leading zeros are also dropped.

Value

A character vector of formatted numbers.

Author(s)

Sercan Kahveci

Examples

format_stat(0.12345678)

# Proper printing of p-values
format_stat(0.0004,type="p")

# Printing of quotients where the range of values between 1 and 0
# should be considered equal to that between 1 and infinity
format_stat(0.05,type="quotient")


Spiritspeak/skMisc documentation built on April 12, 2025, 5:40 a.m.