Rev 27621 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{strwrap}\alias{strwrap}\title{Wrap Character Strings to Format Paragraphs}\description{Each character string in the input is first split into paragraphs (onlines containing whitespace only). The paragraphs are then formattedby breaking lines at word boundaries. The target columns for wrappinglines and the indentation of the first and all subsequent lines of aparagraph can be controlled independently.}\usage{strwrap(x, width = 0.9 * getOption("width"), indent = 0, exdent = 0,prefix = "", simplify = TRUE)}\arguments{\item{x}{a character vector}\item{width}{a positive integer giving the target column for wrappinglines in the output.}\item{indent}{a non-negative integer giving the indentation of thefirst line in a paragraph.}\item{exdent}{a non-negative integer specifying the indentation ofsubsequent lines in paragraphs.}\item{prefix}{a character string to be used as prefix for each line.}\item{simplify}{a logical. If \code{TRUE}, the result is a singlecharacter vector of line text; otherwise, it is a list of the samelength as \code{x} the elements of which are character vectors ofline text obtained from the corresponding element of \code{x}.(Hence, the result in the former case is obtained by unlisting thatof the latter.)}}\details{Whitespace in the input is destroyed. Double spaces after periods(thought as representing sentence ends) are preserved. Currently, itpossible sentence ends at line breaks are not considerd specially.Indentation is relative to the number of characters in the prefixstring.}\examples{## Read in file `THANKS'.x <- paste(readLines(file.path(R.home(), "THANKS")), collapse = "\n")## Split into paragraphs and remove the first three onesx <- unlist(strsplit(x, "\n[ \t\n]*\n"))[-(1:3)]## Join the restx <- paste(x, collapse = "\n\n")## Now for some fun:writeLines(strwrap(x, width = 60))writeLines(strwrap(x, width = 60, indent = 5))writeLines(strwrap(x, width = 60, exdent = 5))writeLines(strwrap(x, prefix = "THANKS> "))}\keyword{character}