pad a character string to a fixed length

padString(
  x,
  stringLength = max(nchar(x)),
  padCharacter = " ",
  justify = "left",
  ...
)

Arguments

x

character vector

stringLength

integer length for the resulting character strings in x. By default, all strings are padded to the length of the longest entry, however stringLength can be defined to impose strict number of characters for all entries.

padCharacter

character string with nchar=1 used for padding.

justify

character string with "left", "right", "center" to indicate alignment of the resulting text string.

...

additional parameters are ignored.

Value

character vector of length(x)

Examples

padString(c("one","two","three"));
#>     one     two   three 
#> "one  " "two  " "three" 
padString(c("one","two","three","four"), padCharacter="_", justify="center");
#>     one     two   three    four 
#> "_one_" "_two_" "three" "_four"