Learn R Programming

qwraps2 (version 0.1.2)

frmt: Format

Description

A function for formating Numeric values for consistent display in reports.

Usage

frmt(x, digits = getOption("qwraps2_frmt_digits", 2))

Arguments

x
a vector of numbers to format
digits
number of digits, including trailing zeros, to the right of the decimal point. This option is ignored if is.integer(x) == TRUE).

Value

  • a character vector of the formatted numbers

Details

This function is really just a wrapper for the formatC.

See Also

frmtp formatC

Examples

Run this code
integers <- c(1234L, 9861230L)
numbers  <- c(1234,  9861230)
frmt(integers)  # no decimal point
frmt(numbers)   # decimal point and zeros to the right

numbers <- c(0.1234, 0.1, 1234.4321, 0.365, 0.375)
frmt(numbers)

Run the code above in your browser using DataLab