format_value {insight} | R Documentation |
format_value()
converts numeric values into formatted string values, where
formatting can be something like rounding digits, scientific notation etc.
format_percent()
is a short-cut for format_value(as_percent = TRUE)
.
format_value(x, ...) ## S3 method for class 'data.frame' format_value( x, digits = 2, protect_integers = FALSE, missing = "", width = NULL, as_percent = FALSE, zap_small = FALSE, lead_zero = TRUE, style_positive = "none", style_negative = "hyphen", ... ) ## S3 method for class 'numeric' format_value( x, digits = 2, protect_integers = FALSE, missing = "", width = NULL, as_percent = FALSE, zap_small = FALSE, lead_zero = TRUE, style_positive = "none", style_negative = "hyphen", ... ) format_percent(x, ...)
x |
Numeric value. |
... |
Arguments passed to or from other methods. |
digits |
Number of digits for rounding or significant figures. May also
be |
protect_integers |
Should integers be kept as integers (i.e., without decimals)? |
missing |
Value by which |
width |
Minimum width of the returned string. If not |
as_percent |
Logical, if |
zap_small |
Logical, if |
lead_zero |
Logical, if |
style_positive |
A string that determines the style of positive numbers.
May be |
style_negative |
A string that determines the style of negative numbers.
May be |
A formatted string.
format_value(1.20) format_value(1.2) format_value(1.2012313) format_value(c(0.0045, 234, -23)) format_value(c(0.0045, .12, .34)) format_value(c(0.0045, .12, .34), as_percent = TRUE) format_value(c(0.0045, .12, .34), digits = "scientific") format_value(c(0.0045, .12, .34), digits = "scientific2") format_value(c(0.045, .12, .34), lead_zero = FALSE) # default format_value(c(0.0045, .123, .345)) # significant figures format_value(c(0.0045, .123, .345), digits = "signif") format_value(as.factor(c("A", "B", "A"))) format_value(iris$Species) format_value(3) format_value(3, protect_integers = TRUE) format_value(head(iris))