str_pad {stringr} | R Documentation |
Vectorised over string
. All other inputs should
be of length 1.
str_pad(string, width, side = "left", pad = " ")
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) |
character vector
str_trim
to remove whitespace
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)