Description Usage Arguments Value Examples
Remove leading zeros and standardize number of digits. A workhorse for the numform package.
1 2 3 4 5 6 7 8 9 10 11 12 |
x |
A vector of numbers (or string equivalents). |
digits |
The number of digits to use. Defaults to 1. Can be set
globally via: |
p |
A string to paste at the beginning of the output from |
s |
A string to paste at the end of the output from |
pad.char |
A character to use for leading padding if lengths of output are unequal. |
zero |
A value to insert in for zero values. |
retain.leading.zero |
logical. If |
... |
ignored. |
Returns a string of publication ready digits.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | f_num(c(0.0, 0, .2, -00.02, 1.122222, pi))
f_num(rnorm(10))
f_num(rnorm(20, 100, 200), 0)
f_num(c("-0.23", "0", ".23"))
## Percents
f_num(c(30, 33.45, .1), 3, s="%")
## Money
f_num(c(30, 33.45, .1), 2, p="$")
## Units
f_num(c(30, 33.45, .1), 2, s=" in.<sup>2</sup>")
f_num(c(30, 33.45, .1), 2, p="Χ<sup>2</sup>=")
## Not run:
library(dplyr)
is.int <- function(x) !all(x %% 1 == 0)
mtcars %>%
mutate_if(.funs = f_num, is.int)
df <- data.frame(x = -10:10, y = (-10:10)/10)
ggplot(df, aes(x, y))+
geom_point() +
scale_y_continuous(labels = ff_num(zero = 0))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.