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 38 39 40 41 42 43 44
|
\name{centerText}
\alias{centerText}
\title{
Center Text Strings
}
\description{
Function to center text strings for display on the text console
by prepending the necessary number of spaces to each element.
}
\usage{
centerText(x, width = getOption("width"))
}
\arguments{
\item{x}{Character vector containing text strings to be centered.}
\item{width}{Desired display width. Defaults to the R display width
given by \code{getOption("width")}.}
}
\details{
Each element will be centered individually by prepending the
necessary number of spaces to center the text in the specified
display width assuming a fixed width font.
}
\value{
Vector of character strings.
}
\author{
Gregory R. Warnes \email{greg@warnes.net}
}
\seealso{
\code{\link[base]{strwrap}}
}
\examples{
cat(centerText("One Line Test"), "\n\n")
mText <-c("This", "is an example",
" of a multiline text ",
"with ",
" leading",
" and trailing ",
"spaces.")
cat("\n", centerText(mText), "\n", sep="\n")
}
\keyword{manip}
\keyword{character}
|