num2str: Format number to be a string beginning with a decimal point.

Description Usage Arguments Value Examples

View source: R/core.R

Description

Format number to be a string beginning with a decimal point.

Usage

1
2
3
4
5
6
7
8
9
num2str(
  num,
  precision = 2,
  isProportion = F,
  truncateZeros = F,
  prefix = "",
  minPrefix = NA,
  ...
)

Arguments

num

number to convert to string

precision

decimal places to preserve

isProportion

whether to strip leading 0 for 0.x values

truncateZeros

whether to strip trailing 0s

prefix

prefix for the number string (e.g. " = ")

minPrefix

for transforming numbers like .000 into < .001

...

discarded arguments used to allow overflowed calls from other functions

Value

num stripped of leading 0s and rounded to precision decimal places

Examples

1
2
3
4
5
data.frame(input = c(seq(-10,10),100), output = num2str(exp(c(seq(-10,10),100)), 4))
data.frame(
  input = c(seq(-10,10),100),
  output = num2str(exp(c(seq(-10,10),100)), 4, isProportion = TRUE)
)

mjaquiery/prettyMD documentation built on Oct. 6, 2021, 4:16 p.m.