File: centerText.R

package info (click to toggle)
gdata 3.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 964 kB
  • sloc: sh: 27; makefile: 15
file content (13 lines) | stat: -rw-r--r-- 368 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
centerText <- function(x, width=getOption("width"))
{
  retval <- vector(length=length(x), mode="character")
  for(i in 1:length(x))
  {
    text <- trim(x[i])
    textWidth  <- nchar(text)
    nspaces <- floor((width - textWidth)/2)
    spaces <- paste(rep(" ",nspaces), sep="", collapse="")
    retval[i] <- paste(spaces, text, sep="", collapse="\n")
  }
  retval
}