units_without_zero: Produce Formatted Unit Without Zero

Description Usage Arguments Value Examples

View source: R/units-without-zeros.R

Description

Convenience wrapper on useful unit_format function offered within scales package. Useful when producing scales without 0: "" "1K" "10K" instead of "0k" "1K" "10K".

Usage

1

Arguments

x

A numeric vector

...

other arguments passed to unit_format

Value

A character vector.

Examples

1
2
3
4
5
6
vec_tst <- c(0, 1000, 1e6)
units_without_zero(vec_tst, unit = "K", scale = 1e-3, sep = "")
# "0"      "1K"     "1,000K"
# For comparison
scales::unit_format(unit = "K", scale = 1e-3, sep = "")(vec_tst)
# [1] "0K"     "1K"     "1,000K"

konradedgar/KEmisc documentation built on April 15, 2021, 1:50 p.m.