Learn R Programming

Publish (version 2023.01.17)

pubformat: Format numbers for publication

Description

Format numbers according to a specified handler function. Currently supported are sprintf, format and prettyNum.

Usage

pubformat(x, digits = 2, nsmall = digits, handler = "sprintf", ...)

Value

Formatted number

Arguments

x

numeric vector

digits

number of digits

nsmall

see handler

handler

String specififying the name of the function which should perform the formatting. See sprintf, format and prettyNum.

...

Passed to handler function if applicable, i.e., not to sprintf.

Author

Thomas A. Gerds <tag@biostat.ku.dk>

See Also

sprintf, format, prettyNum

Examples

Run this code

pubformat(c(0.000143,12.8,1))
pubformat(c(0.000143,12.8,1),handler="format")
pubformat(c(0.000143,12.8,1),handler="format",trim=TRUE)
pubformat(c(0.000143,12.8,1),handler="prettyNum")

Run the code above in your browser using DataLab