vector.print.with.and: Print a vector with commas and a final "and".

Description Usage Arguments Value Examples

Description

Print a vector with commas and a final "and".

Usage

1
2
vector.print.with.and(vector_to_print,
  string_to_return_if_vector_is_empty = "", use_oxford_comma = TRUE)

Arguments

vector_to_print

A vector of strings (or elements able to be coerced into strings) to print.

string_to_return_if_vector_is_empty

If vector_to_print is empty, the string that should be returned (for example, "", "(None)", etc.)

use_oxford_comma

A logical (TRUE/FALSE) value indicating whether to use an Oxford comma ("One, two, and three" vs. "One, two and three").

Value

A single string that concatenates the input, separating with commas and adding "and" before the final item.

Examples

1
2
3
4
5
6
vector.print.with.and(c("One", "Two", "Three", "Four"))
vector.print.with.and(c("One", "Two", "Three", "Four"), use_oxford_comma = FALSE)
vector.print.with.and(c("One", "Two"))
vector.print.with.and(c("One"))
vector.print.with.and(c(), string_to_return_if_vector_is_empty = "(None)") # Outputs "(None)"
vector.print.with.and(c(""), string_to_return_if_vector_is_empty = "(None)") # Outputs ""

Example output

[1] "One, Two, Three, and Four"
[1] "One, Two, Three and Four"
[1] "One and Two"
[1] "One"
[1] "(None)"
[1] ""

veccompare documentation built on May 2, 2019, 7:29 a.m.