leading_zero: Function to add leading zeroes to maintain fixed width.

Description Usage Arguments Details Value Author(s) Examples

View source: R/leading_zero.R

Description

This function ensures that fixed width data is the right length by padding zeroes to the front of values. This is a common problem with fixed width data after importing into R as non-character type.

Usage

1
leading_zero(x, digits = 2)

Arguments

x

a vector of numeric data that should be fixed width but is missing leading zeroes.

digits

an integer representing the desired width of x

Details

If x contains negative values then the width specified by digits will include one space taken up for the negative sign. The function does not trim values that are longer than digits, so the vector produced will not have a uniform width if nchar(x) > d

Value

A character vector of length digits

Author(s)

Jason P. Becker

Jared E. Knowles

Examples

1
2
3
a <- seq(1,10)
a <- leading_zero(a, digits = 3)
a


eeptools documentation built on May 19, 2017, 4:16 p.m.
Search within the eeptools package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.