1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
\name{str_pad}
\alias{str_pad}
\title{Pad a string.}
\usage{
str_pad(string, width, side = "left", pad = " ")
}
\arguments{
\item{string}{input character vector}
\item{width}{pad strings to this minimum width}
\item{side}{side on which padding character is added
(left, right or both)}
\item{pad}{single padding character (default is a space)}
}
\value{
character vector
}
\description{
Vectorised over \code{string}. All other inputs should
be of length 1.
}
\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)
}
\seealso{
\code{\link{str_trim}} to remove whitespace
}
\keyword{character}
|