str_pad {stringr}R Documentation

Pad a string.

Description

Vectorised over string. All other inputs should be of length 1.

Usage

  str_pad(string, width, side = "left", pad = " ")

Arguments

string

input character vector

width

pad strings to this minimum width

side

side on which padding character is added (left, right or both)

pad

single padding character (default is a space)

Value

character vector

See Also

str_trim to remove whitespace

Examples

rbind(
  str_pad("hadley", 30, "left"),
  str_pad("hadley", 30, "right"),
  str_pad("hadley", 30, "both")
)
# Longer strings are returned unchanged
str_pad("hadley", 3)

[Package stringr version 0.6.2 Index]