Add character to left of every character

pad_left(.x, .n, padding_char = "0")

Arguments

.x

vector

.n

total number of characters result should have

padding_char

padding char to use, defaults to 0

Details

Use this function to add specific character to the left of each element in a given vector.

The output is a character vector and default padding character is "0".

Examples

pad_left(1, 3)
#> [1] "001"

pad_left(c(1, 10), 4, "Z")
#> [1] "ZZZ1" "ZZ10"