Learn R Programming

sjmisc (version 1.0.0)

word_wrap: Insert line breaks in long labels

Description

Insert line breaks in long character strings. Useful if you want to wordwrap plot labels.

Usage

word_wrap(labels, wrap, linesep = NULL)

Arguments

labels
The label(s) (i.e. character string). You can also pass several strings as vector (e.g. labels=c("first long string", "second long string"))
wrap
The amount of chars per line (i.e. line length)
linesep
By default, this parameter is NULL and a regular new line string is used. For HTML-needs, for instance, linesep could be "
"
.

Value

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

Examples

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

Run the code above in your browser using DataLab