stformat: format number in a reasonable way

View source: R/stata_related.R

stformatR Documentation

format number in a reasonable way

Description

format number in a reasonable way.

Usage

stformat(
  x,
  digits = 3L,
  nsmall = 3L,
  width = NULL,
  big.mark = ",",
  na.replace = ""
)

Arguments

x,

numeric vector

digits,

how many significant digits are to be used for numeric and complex x. The default, NULL, uses getOption("digits").

nsmall,

the minimum number of digits to the right of the decimal point in formatting real/complex numbers in non-scientific formats.

na.replace,

used to replace NA

width:

default method: the minimum field width or NULL or 0 for no restriction.

Examples

stformat(10 ^ seq(-10, 10) + runif(21))
stformat(10 ^ seq(-10, 10) + runif(21), nsmall = 2)
stformat(10 ^ seq(-10, 10) + runif(21), digits = 4)
stformat(10 ^ seq(-10, 10) + runif(21), width = 7)
stformat(10 ^ seq(-10, 10) + runif(21), width = 11)
stformat(c(NA, 10 ^ seq(-5, 5)) + runif(12))

liubianshi/lbs documentation built on Nov. 2, 2023, 11:06 a.m.