
Last chance! 50% off unlimited learning
Sale ends in
str_pad(string, width, side = "left", pad = " ")
string
. All other inputs should
be of length 1.str_trim
to remove whitespacerbind(
str_pad("hadley", 30, "left"),
str_pad("hadley", 30, "right"),
str_pad("hadley", 30, "both")
)
# Longer strings are returned unchanged
str_pad("hadley", 3)
Run the code above in your browser using DataLab