Digit: Digit

Description Usage Arguments Value Note Author(s) Examples

Description

Digit takes a number and places leading zeros before it if needed to bring the length of the number up to places. Inputs can be either numeric or character but must be integers (e.g., "1" or 1 are okay, 1.5 is not).

Usage

1
Digit(number, places)

Arguments

number

The input number (potentially) in need of leading zeros

places

The number of places the final number should have. Needs to be greater than or equal to one.

Value

A number with leading zeros in character format

Note

I have written a similar function for Python, but with a different implementation.

Author(s)

Alexander "Sasha" Keyel

Examples

1
2
3
4
Digit(10,3)  #010; one leading zero added
Digit(5,3)   #005; two leading zeros added
Digit(200,3) #200; long enough, no leading zeros added
Digit(2000,3) #2000; no leading zeros, no truncation (places 4 would be better)

akeyel/spatialdemography documentation built on May 12, 2019, 4:43 a.m.