pad.string {fame} | R Documentation |
Pads a collection of strings to a desired length to either the left or right with a specified character.
pad.string(x, len = max(nchar(x)), padchar = " ", right = T)
x |
character object |
len |
desired length of the returned strings |
padchar |
a single-character string. |
right |
if TRUE (the default), the strings in x are
padded to the right, else they are padded to the left. |
an object like x
, but with the strings padded out to the
desired length. Strings in x
that are already len
or more
characters long are unaffected by the function.
Jeff Hallman
pad.string(c("aaa", "bbbbbb", "ccccccccccc"), len = 7, padchar = "X")