Free Access Week - Data Engineering + BI
Data Engineering and BI courses are free this week!
Free Access Week - Jun 2-8

gdata (version 2.13.2)

centerText: 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

x
Character vector containing text strings to be centered.
width
Desired display width. Defaults to the R display width given by getOption("width").

Value

  • Vector of character strings.

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.

See Also

strwrap

Examples

Run this code
cat(centerText("One Line Test"), "")

mText <-c("This", "is an example",
          "of a multiline text    ",
          "with ",
          "leading",
          "and trailing         ",
          "spaces.")
cat("", centerText(mText), "", sep="")

Run the code above in your browser using DataLab