Learn R Programming

SciencesPo (version 1.3.9)

textwrap: Insert line breaks in long strings

Description

Insert line breaks in long character strings. Useful for wrapping labels / titles for plots and tables.

Usage

textwrap(labels, wrap, linesep = NULL)

Arguments

labels
Label(s) as character string, where a line break should be inserted. Several strings may be passed as vector (see 'Examples').
wrap
Maximum amount of chars per line (i.e. line length). If code{wrap = Inf}, no word wrap will be performed (i.e. labels will be returned as is).
linesep
By default, this argument is NULL and a regular new line string ("\n") is used. For HTML-purposes, for instance, linesep could be "
"
.

Value

  • New label(s) with line breaks inserted at every wrap's position.

Examples

Run this code
textwrap(c("A very long string", "And another even longer string!"), 10)

Run the code above in your browser using DataLab