Converts a numeric vector into strings rounded to a significant-figure-like
number of digits. Scientific notation is avoided, and additional
significant figures may be displayed for large numbers: with 2 significant
figures requested, 123 is displayed as "123" rather than "120" or
"1.2e2".
Arguments
- x
(
numeric)
Numeric vector.- digits
(
integer)
Number of significant figures.- scale
(
scalar numeric)
Values are multiplied byscalebefore rounding, e.g.scale = 100to show a proportion as a percentage.- big.mark
(
string)
Character used between every three digits to the left of the decimal mark.- decimal.mark
(
string)
Character used as the decimal mark.- prefix, suffix
(
string)
Text added before and after each formatted value.- na
(
string)
Replacement for missing values.- ...
Not used. Accepted so that formatting functions can be called interchangeably.
Details
Scientific notation output is avoided.
If 2 significant figures are requested, the number is rounded to no more than 2 decimal places: a number is rounded to 2 decimal places when
abs(x) < 1, to 1 decimal place whenabs(x) >= 1 & abs(x) < 10, and to the nearest integer whenabs(x) >= 10.Additional significant figures may be displayed for large numbers.
See also
Other style helpers:
label_style,
style_number(),
style_percent(),
style_pvalue(),
style_ratio()