wrap_lines: Wrap strings across lines

Description Usage Arguments Value See Also Examples

Description

Wrap strings across lines

Usage

1
2
wrap_lines(x, n, sep = "\n", max_lines = Inf, dots = "...",
  hard = FALSE, tol = if (hard) 0L else 3L)

Arguments

x

Strings to be wrapped

n

Number of characters per line after wrapping

sep

Separator used for combining lines

max_lines

Wrap every string to at most ‘max_lines’ lines

dots

String to be inserted to indicate that a string was truncated

hard

TRUE if lines should have a fixed length of ‘n’ even if that means line breaks in the middle of a word

tol

Lines will be allowed to be ‘tol’ characters longer than ‘n’ if that makes the line lengths more even overall

Value

A list of strings each of which spans at most ‘max_lines’ physical lines of length 1 to ‘n + tol’.

See Also

group_words

Examples

1
2
3
s <- "The quick yellow-orange-red-brown fox jumps over a 3-year-old, lazy dog."
pr(wrap_lines(s, 12))
pr(wrap_lines(s, 12, hard = TRUE))

cbaumbach/miscFun documentation built on May 13, 2019, 1:48 p.m.