strwrap
Wrap Character Strings for Paragraph Formatting

Description

Breaks up character strings at spaces into strings of specified width so they can be printed as paragraphs.

Usage

strwrap(x, width=0.9 * options()$width, indent=0, exdent=0,
   prefix="", simplify=TRUE, initial=prefix)

Arguments

x a character vector. The character strings in it should consist of words separated by spaces or tabs.
width a positive integer indicating the desired maximum length of an output string.
indent a non-negative integer indicating how many spaces to insert at the start of each output paragraph.
exdent a non-negative integer indicating how many spaces to insert at the start of each non-initial line in an output paragraph.
prefix a character string to prepend to each non-empty line.
simplify a logical. The default TRUE produces a single character vector of line text. Otherwise, it produces a list of the same length as x. In this case, the elements of the resulting list are character vectors of the line text obtained from the corresponding element of x.
initial a character string to be used like the prefix argument on the first non-empty line.

Details

Any white space contained in the input is removed. Double spaces after periods are retained.
See Also
writeLines
Examples
txt <- c("Jane can run quickly.  So can Dick.",
         "",
         "The quick red fox jumped over the lazy brown dog.")
writeLines(strwrap(txt, width = 25))
writeLines(strwrap(txt, width = 30, indent=5))
writeLines(strwrap(txt, width = 30, exdent=5))
Package base version 6.0.0-69
Package Index