Learn R Programming

Kmisc (version 0.5.0)

wrap: Wrap a String

Description

This function operates similarily to strwrap, but pastes the wrapped text back together with line separators. Useful for automatically wrapping long labels.

Usage

wrap(x, width = 8, ...)

Arguments

x
A character vectors, or an object which can be converted to a character vector by as.character.
width
A positive integer giving the number of characters a line can reach before we wrap and introduce a new line.
...
Optional arguments passed to strwrap.

Examples

Run this code
long_label <- "This is a very long label which needs wrapping."
wrap(long_label)

Run the code above in your browser using DataLab