format.pct: Format proportions as percentages for printing

View source: R/format.pct.R

format.pctR Documentation

Format proportions as percentages for printing

Description

format.pct prepares proportions as percentages for results printing, possibly with a percent sign.

Usage

## S3 method for class 'pct'
format(p, digits = 1, pct.symbol = TRUE)

Arguments

p

a numeric vector assumed to be a proportion.

digits

the number of decimal digits to be used in the output.

pct.symbol

(logical) whether or not to include the percent sign in the output.

Details

This function multiplies the proportion by 100, formats with the given number of decimal digits. It also (optionally) includes a percent sign.

Value

A character value formatted as percentages

Author(s)

Felipe Figueiredo

Examples

format.pct(.1)
format.pct(c(.42, .99), 0)

m <- 10*matrix(c(1, 1.1, .9, 2), nrow = 2)
format.pct(fisher.test(m)$p.value)
format.pct(fisher.test(5*m)$p.value)
format.pct(fisher.test(m)$conf.int)


philsf/philsfmisc documentation built on April 11, 2022, 9:04 p.m.