# formatPval: Format P Values In reporttools: Generate "LaTeX"" Tables of Descriptive Statistics

## Description

`formatPval` is intended for formatting p-values, and is based on the function `format.pval` in the base R-package.

## Usage

 ```1 2 3``` ```formatPval(pv, digits = max(1, getOption("digits") - 2), eps = 0.0001, na.form = "NA", scientific = FALSE, includeEquality=FALSE) ```

## Arguments

 `pv` a numeric vector. `digits` how many significant digits are to be used. `eps` a numerical tolerance: see ‘Details’. `na.form` character representation of `NA`s. `scientific` use scientific number format (not by default) `includeEquality` include equality signs in front of the large p-values? (not by default)

## Details

`formatPval` is mainly an auxiliary function for the family of table functions, but can also be useful on its own. If a p-value is smaller than `eps`, we return just that it is smaller than the threshold but no longer the exact value. This function is more general than `format.pval` the behaviour of which can (almost) be obtained by using the options `eps = .Machine\$double.eps` and `scientific = TRUE`.

## Value

A character vector.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ```## include equality signs? formatPval(c(stats::runif(5), pi^-100, NA)) formatPval(c(stats::runif(5), pi^-100, NA), include=TRUE) ## try another eps argument formatPval(c(0.1, 0.0001, 1e-7)) formatPval(c(0.1, 0.0001, 1e-7), eps=1e-7) ## only the white space can differ with the base function result: (a <- formatPval(c(0.1, 0.0001, 1e-27), eps = .Machine\$double.eps, scientific = TRUE)) (b <- format.pval(c(0.1, 0.0001, 1e-27))) all.equal(a, b) ```

### Example output

```Loading required package: xtable
 "0.86"     "0.16"     "0.37"     "0.91"     "0.72"     "< 0.0001" "NA"
 "= 0.93"   "= 0.43"   "= 0.34"   "= 0.33"   "= 0.28"   "< 0.0001" "NA"
 "0.10"     "0.0001"   "< 0.0001"
 "0.10"      "0.0001"    "0.0000001"
 "0.10"    "0.0001"  "< 2e-16"
 "1e-01"  "1e-04"  "<2e-16"
 "3 string mismatches"
```

reporttools documentation built on Oct. 12, 2021, 5:06 p.m.