collapse_to_sentence: Collapse a character vector to a list suitable for an English...

Description Usage Arguments Value Examples

View source: R/collapse.R

Description

Collapse a character vector to a list suitable for an English sentence.

Usage

1
2
collapse_to_sentence(vector, conjunction = "and", oxford_comma = TRUE,
  terminal_period = FALSE)

Arguments

vector

The character vector to collapse (2 or more elements).

conjunction

The word to use as a conjunction (no spaces).

oxford_comma

Logical indicating whether the oxford comma should be used.

terminal_period

Logical indicating whether a period should be appended.

Value

A single element character vector containing all the elements of vector separated by commas and conjoined by conjunction.

Examples

1
2
3
collapse_to_sentence(c("eats", "shoots", "leaves"), oxford_comma = FALSE)
collapse_to_sentence(c("my way", "the highway"), conjunction = "or")
collapse_to_sentence(1:10, conjunction = "or", terminal_period = TRUE)

seaaan/easieR documentation built on May 29, 2019, 4:23 p.m.