Skip to contents

Deduplicate and remove trailing line breaks

Usage

squish_newlines(sepstring)

Arguments

sepstring

A character vector with new line control characters.

Value

A vector without trailing or multiple consecutive new line sequences.

Details

Useful for tables with merged cells, often imported from Word or PDF files. Can be applied across multiple columns before separating into rows.

Examples

vecWithNewlines <- c("dog\n\ncat\n\n\npig\n")
squish_newlines(vecWithNewlines)
#> [1] "dog\ncat\npig"