write_out: Write out a list of words

Description Usage Arguments Value Examples

View source: R/write.R

Description

Write out a list of words

Usage

1
2
3
4
5
6
write_out(word_list, quoted = FALSE, human = TRUE,
  separator = ifelse(sum(grepl(",", word_list)), ";", ","),
  placement = ifelse(human & grepl("United States", Sys.getlocale()),
  "US", "international"), oxford = TRUE, quote_type = c("double",
  "single"), curly = human, collapse = c("and", "&", "+", "or",
  "and/or"), ending = c("", ".", ","))

Arguments

word_list

Character vector. Words to be listed out.

quoted

Logical. If TRUE, will wrap each word in quotation marks.

human

Logical. If FALSE, will leave out the final conjunction.

separator

Character. What punctuation do you want between elements? Defaults to semicolon if any element contains a comma, comma otherwise.

placement

Character. If "US", will place commas and periods inside any quotation marks (and other punctuation outside them). If "international", will place all punctuation outside quotation marks. Defaults to "US" if Sys.getlocale places you in the US and human is set to TRUE.

oxford

Logical. Use an Oxford comma? Defaults to TRUE. Parameter is ignored if separator is not a comma.

quote_type

Character. "double" for double quotes, "single" for single.

curly

Logical. TRUE for Unicode curly quotes, FALSE for straight ASCII quotes. Defaults to FALSE if human == FALSE, TRUE otherwise.

collapse

Character. What final conjunction or sign do you want? "and", an ampersand, a plus sign, an "or", an "and/or"...?

ending

Character (e.g. period, comma, or zero-length string). What character if any do you need inside the final quotation mark, or at the end of the function"s output?

Value

Character. A pretty, human-readable list.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
write_out("apples")
write_out(c("apples", "oranges"))
write_out(c("apples", "oranges"), quoted = TRUE)
write_out(
  c("hello, my friend", "welcome", "enter"),
  quoted = TRUE,
  ending = "."
)
write_out(c("apples", "oranges"), quoted = TRUE, quote_type = "single")
write_out(
  c("apples", "oranges"),
  quoted = TRUE,
  quote_type = "single",
  curly = FALSE
)
write_out(c("apples", "oranges", "bananas"))
write_out(c("apples", "oranges", "bananas"), quoted = TRUE, ending = ".")
write_out(c("apples", "oranges", "bananas"), oxford = FALSE)
write_out(c("apples", "oranges", "bananas"), collapse = "or")
write_out(c("apples", "oranges", "bananas"), human = FALSE)
write_out(character(0))

BenjaminWolfe/typewritr documentation built on Nov. 23, 2019, 11:18 a.m.