padString function

pad a character string to a fixed length

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.

Returns

character vector of length(x)

Examples

padString(c("one","two","three")); padString(c("one","two","three","four"), padCharacter="_", justify="center");

See Also

Other jam string functions: asSize(), breaksByVector(), fillBlanks(), formatInt(), gsubOrdered(), gsubs(), makeNames(), nameVector(), nameVectorN(), padInteger(), pasteByRow(), pasteByRowOrdered(), sizeAsNum(), tcount(), ucfirst()

  • Maintainer: James M. Ward
  • License: MIT + file LICENSE
  • Last published: 2025-03-23