Learn R Programming

pystr (version 2.0.0)

pystr_zfill: Zero-pad a string.

Description

Return a copy of the string left filled with ASCII '0' digits to make a string of length width.

Usage

pystr_zfill(str, width)

Arguments

str
A character vector.
width
An integer.

Value

A character vector.

Details

A leading sign prefix (+/-) is handled by inserting the padding after the sign character rather than before. The original string is returned if width is less than or equal to nchar(str).

References

https://docs.python.org/3/library/stdtypes.html#str.zfill

Examples

Run this code
pystr_zfill("42", 5)
pystr_zfill("-42", 5)
pystr_zfill("+42", 5)

Run the code above in your browser using DataLab