SciencesPo (version 1.3.9)

rounded: Round Numbers Without Leading Zeros

Description

Given a numeric vector, round numbers with no leading zeros. Something nice for a plot or publicatio.

Usage

rounded(x, digits = 2, add = FALSE, max = (digits + 2))

Arguments

x
A numeric vector.
digits
An integer for the number of digits to round to.
add
Logical, whether additional digits are to be added if no number appears in the pre-set digit level, default is FALSE.
max
The Maximum number of digits to be shown, only affects if add=TRUE.

Value

  • A vector of the same length of x, but stored as string.

encoding

UTF-8

Examples

Run this code
x = seq(0, 1, by=.1)
rounded(x)

Run the code above in your browser using DataLab