Learn R Programming

easyr (version 0.5-2)

fmat: Number Formatter

Description

Flexible number formatter for easier formatting from numbers and dates into characters for display.

Usage

fmat(x = NULL, type = c("auto", ",", "$", "%", ".", "mdy", "ymd",
  "date", "dollar", "dollars", "count", "percentage", "decimal"),
  do.return = c("formatted", "highcharter"), digits = NULL,
  with.unit = FALSE, do.date.sep = "/", do.remove.spaces = FALSE,
  digits.cutoff = NULL)

Arguments

x

Vector of values to convert. If retu

type

Type of format to return. If do.return == 'highcharter' this is not required.

do.return

Information to return. "formatted" returns a vector of formatted values.

digits

Number of digits for rounding. If left blank, the funtion will guess at the best digits.

with.unit

For large numbers, choose to add a suffix for fewer characters, like M for million, etc.

do.date.sep

Separator for date formatting.

do.remove.spaces

Remove extra spaces in return.

digits.cutoff

Amount at which to show 0 digits. Allows for flexibility of rounding.

Value

Information requested via do.return.

Examples

Run this code
# NOT RUN {
fmat( 1000, 'dollar', digits = 2 )

# }

Run the code above in your browser using DataLab