comma: Formats rounded characters nicely for print purposes

View source: R/comma.R

commaR Documentation

Formats rounded characters nicely for print purposes

Description

This function is useful if used in Rmarkdown documents or when used to print nice tables.

Usage

comma(x, digits = 1, trailing = FALSE)

Arguments

x

A numeric object to modify

digits

Desired number of digits after the decimal point

trailing

Should trailing zeroes be preserved? Default = FALSE

Value

A properly formatted character object

Examples


x <- 200.00
comma(x, digits = 1)
# "200"
comma(x, digits = 1, trailing = TRUE)
# "200.0"

bsurial/bernr documentation built on Nov. 7, 2022, 1:41 a.m.