leading0: Numeric to Character with Leading Zero(s)

Description Usage Arguments Value Author(s) Examples

Description

Transform numeric values to character string prepending leading zero(s).

Usage

1
leading0(num, digits = 2)

Arguments

num

Numeric vector (character also possible) to transform.

digits

Numeric value of minimum length of output strings.

Value

Character vector with same length of strings of each value. Original "string" is prepended by zero(s). String length is at least max(nchar(as.character(num))).

Author(s)

Sven E. Templer sven.templer@gmail.com

Examples

1
2
3
4
5
6
#

# use with paste to generate strings of equal size:
paste0("observation", leading0(1:10, 3))

#

setempler/miscset documentation built on May 29, 2019, 8 p.m.