leading0 {miscset}R Documentation

Numeric to Character with Leading Zero(s)

Description

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

Usage

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

#

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

#

[Package miscset version 1.1.0 Index]