Learn R Programming

radiant.data (version 0.8.1)

formatnr: Format a number with a specified number of decimal places, thousand sep, and a symbol

Description

Format a number with a specified number of decimal places, thousand sep, and a symbol

Usage

formatnr(x, sym = "", dec = 2, perc = FALSE, mark = ",")

Arguments

x

Number or vector

sym

Symbol to use

dec

Number of decimal places

perc

Display number as a percentage

mark

Thousand separator

Value

Character (vector) in the desired format

Examples

Run this code
# NOT RUN {
formatnr(2000, "$")
formatnr(2000, dec = 4)
formatnr(.05, perc = TRUE)
formatnr(c(.1, .99), perc = TRUE)
formatnr(data.frame(a = c(.1, .99)), perc = TRUE)
formatnr(data.frame(a = 1000), sym = "$", dec = 0)

# }

Run the code above in your browser using DataLab