Learn R Programming

qwraps2 (version 0.1.2)

frmtp: Format P-values

Description

A function for formating P-values in general and in journal specific formats.

Usage

frmtp(x, style = getOption("qwraps2_journal", "default"),
  digits = getOption("qwraps2_frmtp_digits", 4),
  markup = getOption("qwraps2_markup", "latex"),
  case = getOption("qwraps2_frmtp_case", "upper"),
  leading0 = getOption("qwraps2_frmtp_leading0", TRUE), ...)

Arguments

x
a vector of P-values to format
style
a character string indicating a specific journal requirements for p-value formatting.
digits
number of digits to the right of the decimal point.
markup
a character string indicating if the output should be latex or markup.
case
a character string indicating if the output should be upper case or lower case.
leading0
boolean, whether or not the p-value should be reported as 0.0123 (TRUE, default), or .0123 (FALSE).
...
Not currently implemented.

Value

  • a character vector of the formatted p-values

Details

The single function call to frmtp formats P-values per journal requirements. As I work on papers aimed at different journals, the formatting functions will be extended to match.

Default settings are controlled through the function arguments but should be set via options().

Default settings report the P-value exactly if P > getOptions("qwraps2_frmtp_digits", 4) and reports P < 10^-(getOptions("qwraps2_frmtp_digits", 2)) otherwise. By the leading zero is controlled via getOptions("qwraps2_frmtp_leading0", TRUE) and a upper or lower case P is controlled by getOptions("qwraps2_frmtp_case", "upper"). These options are ignored if style != "default".

Journals with predefined P-value formatting are noted in the qwraps2 documentation.

See Also

frmt

Examples

Run this code
ps <- c(0.2, 0.001, 0.00092, 0.047, 0.034781, 0.0000872, 0.787, 0.05, 0.043)
# LaTeX is the default markup language
cbind("raw"      = ps,
      "default"  = frmtp(ps),
      "3lower"   = frmtp(ps, digits = 3, case = "lower"),
      "PediDent" = frmtp(ps, style = "pediatric_dentistry"))

# Using markdown
cbind("raw"      = ps,
      "default"  = frmtp(ps, markup = "markdown"),
      "3lower"   = frmtp(ps, digits = 3, case = "lower", markup = "markdown"),
      "PediDent" = frmtp(ps, style = "pediatric_dentistry", markup = "markdown"))

Run the code above in your browser using DataLab