Learn R Programming

lessR (version 3.4.6)

xP: Text Processing: Print Formatted Numbers

Description

Prints numbers nicely formatted, with optional units. Primarily for internal use in text processing of knitr output. Not usually referenced by the user.

Usage

xP(x, d=NULL, unit=NULL, semi=FALSE)

Arguments

x
The variable.
d
The digits.
unit
Unit of measurement for the variable.
semi
Add a semicolon before the unit to add some horizontal spacing in math mode.

Details

Input is numeric, output is formatted text. A special unit is "$", which is added to the front of the number instead of as a trailing descriptor.

Examples

Run this code
xP(12345678.9, d=2, unit="$")

xP(12345678.9, d=2, unit="lbs")

Run the code above in your browser using DataLab