Learn R Programming

parameters (version 0.1.0)

format_value: Numeric Values Formatting

Description

Numeric Values Formatting

Usage

format_value(x, digits = 2, protect_integers = FALSE, missing = "",
  ...)

Arguments

x

Numeric value.

digits

Number of significant digits.

protect_integers

Should integers be kept as integers (i.e., without decimals)?

missing

Value by which `NA` values are replaced. By default, an empty string (i.e. "") is returned for `NA`.

...

Arguments passed to or from other methods.

Value

A formatted string.

Examples

Run this code
# NOT RUN {
format_value(1.20)
format_value(1.2)
format_value(1.2012313)
format_value(c(0.0045, 234, -23))

format_value(as.factor(c("A", "B", "A")))
format_value(iris$Species)

format_value(3)
format_value(3, protect_integers = TRUE)

format_value(iris)
# }

Run the code above in your browser using DataLab