Examples for 'stringr::str_pad'


Pad a string to minimum width

Aliases: str_pad

Keywords:

### ** Examples

rbind(
  str_pad("hadley", 30, "left"),
  str_pad("hadley", 30, "right"),
  str_pad("hadley", 30, "both")
)
     [,1]                            
[1,] "                        hadley"
[2,] "hadley                        "
[3,] "            hadley            "
# All arguments are vectorised except side
str_pad(c("a", "abc", "abcdef"), 10)
[1] "         a" "       abc" "    abcdef"
str_pad("a", c(5, 10, 20))
[1] "    a"                "         a"           "                   a"
str_pad("a", 10, pad = c("-", "_", " "))
[1] "---------a" "_________a" "         a"
# Longer strings are returned unchanged
str_pad("hadley", 3)
[1] "hadley"

[Package stringr version 1.5.1 Index]