squish_whitespace: Remove Extra Whitespace

View source: R/clean.R

squish_whitespaceR Documentation

Remove Extra Whitespace

Description

This function is mostly a wrapper around str_squish, with the additional option to remove hyphens at the ends of lines.

Usage

squish_whitespace(text, remove_terminal_hyphens = TRUE)

Arguments

text

A character vector to clean.

remove_terminal_hyphens

Logical; should hyphens at the end of lines after a word be removed? For example, "un-\nbroken" would become "unbroken".

Value

The character vector with spacing at the start and end removed, and with internal spacing reduced to a single space character each.

Examples

sample_text <- "This  had many space char-\\nacters."
squish_whitespace(sample_text)

piecemaker documentation built on June 7, 2023, 5:55 p.m.