Convert numeric to character with padding

Share:

Description

Convert numeric to character with padding

Usage

1
paddedFloatToChar(x, padL = ceiling(log10(x + 1)), padR = 3, pad = "0")

Arguments

x

numeric. Number to be converted to character with padding

padL

numeric. Desired number of digits on left side of decimal. If not enough, pad will be used to pad.

padR

numeric. Desired number of digits on right side of decimal. If not enough, pad will be used to pad.

pad

character to use as padding (nchar(pad)==1 must be TRUE). Passed to str_pad

Value

Character string representing the filename.

Author(s)

Eliot McIntire and Alex Chubaty

Examples

1
2
paddedFloatToChar(1.25)
paddedFloatToChar(1.25, padL = 3, padR = 5)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.