Function that converts a vector to an English language list: e.g. 1:3 becomes 1, 2 and 3
convertVector2sentence.Rd
Function that converts a vector to an English language list: e.g. 1:3 becomes 1, 2 and 3
Usage
convertVector2sentence(
x,
andChar = " and ",
quoted = FALSE,
quoteChar = "\"",
italicY = FALSE
)
convertVectorToSentence(
x,
andChar = " and ",
quoted = FALSE,
quoteChar = "\"",
italicY = FALSE
)
See also
hyphenateWords
for another utility function to
convert numbers to English words, e.g. "87" to "eighty-seven".
Other text utilities:
hyphenateWords()
Other converting utilities:
convert2CEdate()
Examples
### default behaviour
convertVector2sentence(1:4)
#> [1] "1, 2, 3 and 4"
### [1] "1, 2, 3 and 4"
### default behaviour
convertVector2sentence(1:4, quoted = TRUE)
#> [1] "\"1\", \"2\", \"3\" and \"4\""
### [1] "\"1\", \"2\", \"3\" and \"4\""
### change andChar (note the spaces,
### I can't see why you wouldn't want them but ...)
convertVector2sentence(1:4, andChar = ' & ')
#> [1] "1, 2, 3 & 4"
### [1] "1, 2, 3 & 4"
### change the quoting character (note no spaces)
convertVector2sentence(1:4, quoted = TRUE, quoteChar = "'")
#> [1] "'1', '2', '3' and '4'"
### [1] "'1', '2', '3' and '4'"
convertVector2sentence(1:4, italicY = TRUE) # italicises the items
#> [1] "*1*, *2*, *3* and *4*"
### and now italics and quotation:
convertVector2sentence(1:4, italicY = TRUE, quoted = TRUE)
#> [1] "*\"1*\", \"*2*\", \"*3\"* and *\"4\"*"