Skip to contents

Renders a character vector as "a", "a and b" or "a, b and c", with a fixed placeholder for the empty case. Sentences that enumerate results — which contrasts cleared a threshold, which arms were excluded — should be generated for the same reason the numbers are: the hand-written version is right until the analysis changes.

Usage

cr_enumerate(x, conjunction = "and", empty = "none", oxford = FALSE)

Arguments

x

Character vector. NA and empty strings are dropped.

conjunction

Word joining the last two elements.

empty

Text returned when nothing is left.

oxford

Whether to place a comma before the conjunction.

Value

A single string.

Examples

cr_enumerate(c("CompoundA", "CompoundB", "CompoundC"))
#> [1] "CompoundA, CompoundB and CompoundC"
cr_enumerate(c("CompoundA", "CompoundB"), conjunction = "or")
#> [1] "CompoundA or CompoundB"
cr_enumerate(character())
#> [1] "none"