add_newlines: Insert newlines into text every nth character.

View source: R/strings.R

add_newlinesR Documentation

Insert newlines into text every nth character.

Description

Returns a character string with newlines every nth character. Works for character vectors too.

Usage

add_newlines(x, line_length = 95)

Arguments

x

(chr vector) The strings to split with newlines.

line_length

(num scalar) The desired max length of each line. Defaults to 95 (suitable for ggplot2).

Examples

set.seed(2)
add_newlines(paste0(sample(c(letters, " "), size = 100, replace = T), collapse = ""))

Deleetdk/kirkegaard documentation built on April 1, 2024, 2:23 a.m.