str_wrap: Wrap character vectors

View source: R/string.R

str_wrapR Documentation

Wrap character vectors

Description

A wrapper function to make strwrap() return a character vector of the same length as the input vector; each element of the output vector is a string formed by concatenating wrapped strings by ⁠\n⁠.

Usage

str_wrap(...)

Arguments

...

Arguments passed to strwrap().

Value

A character vector.

Examples

x = sample(c(letters, " "), 200, TRUE, c(rep(0.5/26, 26), 0.5))
x = rep(paste(x, collapse = ""), 2)
strwrap(x, width = 30)
xfun::str_wrap(x, width = 30)  # same length as x

xfun documentation built on April 3, 2025, 7:04 p.m.