prependZeros {WGCNA} | R Documentation |
Pad numbers with leading zeros to specified total width
Description
These functions pad the specified numbers with zeros to a specified total width.
Usage
prependZeros(x, width = max(nchar(x)))
prependZeros.int(x, width = max(nchar(as.integer(x))))
Arguments
x |
Vector of numbers to be padded. For |
width |
Width to pad the numbers to. |
Details
The prependZeros.int
version works better with numbers such as 100000 which may get converted to character as 1e5 and
hence be incorrectly padded in the prependZeros
function. On the flip side, prependZeros works also for non-integer
inputs.
Value
Character vector with the 0-padded numbers.
Author(s)
Peter Langfelder
Examples
prependZeros(1:10)
prependZeros(1:10, 4)
# more exotic examples
prependZeros(c(1, 100000), width = 6) ### Produces incorrect output
prependZeros.int(c(1, 100000)) ### Correct output
prependZeros(c("a", "b", "aa")) ### pads the shorter strings using zeros.
[Package WGCNA version 1.72-5 Index]