Skip to contents

std_chr() standardizes character vectors to ASCII text with no unnecessary whitespace and a given case. By default, it will retain newlines inside text, though it will condense consecutive newlines and any carriage returns into a single newline.

Usage

std_chr(
  x,
  case = c("upper", "lower", "title", "sentence"),
  keep_inner_newlines = TRUE,
  na = "^$"
)

Arguments

x

A character vector

case

The case to convert to. NULL will skip case conversion.

keep_inner_newlines

Whether to retain line breaks inside text. FALSE will treat newlines and carriage returns identically to any other whitespace.

na

Regex patterns to consider NA. Passed to stringr::str_detect(). Can be a vector of patterns.

Value

The standardized character vector