Debian Codegraph @

man/join_words.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/string.R
3 \name{join_words}
4 \alias{join_words}
5 \title{Join multiple words into a single string}
6 \usage{
7 join_words(
8 words,
9 sep = ", ",
10 and = " and ",
11 before = "",
12 after = before,
13 oxford_comma = TRUE
14 )
15 }
16 \arguments{
17 \item{words}{A character vector.}
18
19 \item{sep}{Separator to be inserted between words.}
20
21 \item{and}{Character string to be prepended to the last word.}
22
23 \item{before, after}{A character string to be added before/after each word.}
24
25 \item{oxford_comma}{Whether to insert the separator between the last two
26 elements in the list.}
27 }
28 \value{
29 A character string marked by \code{\link[=raw_string]{raw_string()}}.
30 }
31 \description{
32 If \code{words} is of length 2, the first word and second word are joined by the
33 \code{and} string; if \code{and} is blank, \code{sep} is used. When the length is greater
34 than 2, \code{sep} is used to separate all words, and the \code{and} string is
35 prepended to the last word.
36 }
37 \examples{
38 join_words("a")
39 join_words(c("a", "b"))
40 join_words(c("a", "b", "c"))
41 join_words(c("a", "b", "c"), sep = " / ", and = "")
42 join_words(c("a", "b", "c"), and = "")
43 join_words(c("a", "b", "c"), before = "\"", after = "\"")
44 join_words(c("a", "b", "c"), before = "\"", after = "\"", oxford_comma = FALSE)
45 }