str_flatten: Extended str_flatten function

View source: R/utils.R

str_flattenR Documentation

Extended str_flatten function

Description

A version of stringr::str_flatten() with support for removing empty (zero-length) strings prior to flattening.

Usage

str_flatten(
  s,
  collapse = "",
  last = NULL,
  na.rm = FALSE,
  rm.empty = TRUE,
  unique = TRUE
)

str_flatten_comma(
  s,
  last = NULL,
  na.rm = FALSE,
  rm.empty = TRUE,
  unique = TRUE
)

Arguments

s

Input vector. Either a character vector or something coercible into one.

collapse

String to insert between each piece. Defaults to "".

last

Optional string to use in place of the final separator.

na.rm

Remove missing values?

rm.empty

Remove empty values? If TRUE, empty strings "" are removed. Sets na.rm=TRUE as well.

unique

Uniquify string vector before collapsing.

Value

A string, i.e. a character vector of length 1.

Functions

  • str_flatten_comma(): variation designed to mirror stringr::str_flatten_comma() but with removing empty strings.

See Also

stringr::str_flatten()

str_flatten_comma()


steveneschrich/pgreportr documentation built on Jan. 13, 2025, 7:09 p.m.