Learn R Programming

tldr (version 0.3.0)

write_p: Format a p-value for display

Description

write_p formats a p-value for display in an RMarkdown document.

Usage

write_p(x, digits = 2)

Value

Returns a LaTeX-formatted string to report a p-value to the specified number of digits.

Arguments

x

A length-1 numeric or a list-like object with element named p.value (such as an htest object)

digits

Number of digits to round to (default to 2)

Details

If x < 10^(-digits), then the result is the string p < 10^(-digits) in decimal notation.

Examples

Run this code
write_p(0.2345)

write_p(0.000234)

x = rnorm(10)
test1 = t.test(x)
write_p(test1)

Run the code above in your browser using DataLab