Learn R Programming

rock (version 0.9.6)

split_long_lines: Split long lines

Description

This function splits long lines at a given number of characters, keeping words intact. It's basically a wrapper around strwrap().

Usage

split_long_lines(
  x,
  length = 60,
  collapseResult = FALSE,
  splitString = rock::opts$get("utteranceMarker")
)

Value

A character vector.

Arguments

x

The string (e.g. a source)

length

The maximum length

collapseResult

Whether to collapse the result from a vector (with line breaks separating the elements) to a single character value (where the vector elements are glued together using splitString) or not.

splitString

The character to use to split lines.

Examples

Run this code
cat(
  rock::split_long_lines(
    paste0(
      "Lorem ipsum dolor sit amet, consectetur adipiscing elit. ",
      "Vestibulum et dictum urna. Donec neque nunc, lacinia vitae ",
      "varius vitae, pretium quis nibh. Aliquam pulvinar, lacus ",
      "sed varius vulputate, justo nibh blandit quam, ",
      "nec sollicitudin velit augue eget erat."
    )
  )
);

Run the code above in your browser using DataLab