Wrap Character Strings for Paragraph Formatting

DESCRIPTION:

In the character string specified by x, which contains white spaces, the string is made into a paragraph. Empty lines also delineate paragraphs.

USAGE:

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

REQUIRED ARGUMENTS:

x
The character string. Must contain white spaces to convert to paragraph.

OPTIONAL ARGUMENTS:

width
A positive integer indicating the length, in characters, before the line wrap.
indent
A non-negative integer indicating by how much the first line of each paragraph should be indented.
exdent
A non-negative integer indicating by how much the subsequent lines should be indented. (If indent is null, and exdent is not null, the result is a hanging indented paragraph.)
prefix
A character string to prepend to each paragraph.
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.

DETAILS:

Any white space contained in the input is removed. Double spaces after periods are retained.

SEE ALSO:

EXAMPLES:

## Read in file 'FIXEDBUG.TXT'.
docdir <- "doc"  # set to "help" on Windows
x <- paste(readLines(file.path(system.file(), docdir, "FIXEDBUG.TXT")), collapse = "\n")
## Split into paragraphs
x <- unlist(strsplit(x, "\n[ \t\n]*\n"))
## Join the rest
x <- 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 = "FIXED> "))