str_comma | R Documentation |
str_comma
combines multiple character strings into one and makes them
more readable by separating those strings with commas and "and" as
appropriate. The place I had in mind for using this is in RMarkdown documents
where you want to insert a comment in the text that calls on a character
vector. For example, say you want to note in a text chunk which subjects in a
study have some measurement that is two standard deviations above the mean.
Rather than using only, e.g., stringr::str_c(StudyOutliers, collapse =
", ")
, you could have it include the "and" in the appropriate location and
make your final document more polished, readable, and professional.
str_comma(x, oxford = TRUE)
x |
values to be concatenated |
oxford |
TRUE or FALSE for whether to use the Oxford comma |
Returns a single, collapsed character string
str_comma(LETTERS[1:2])
str_comma(LETTERS[1:4])
str_comma(LETTERS[1:4], oxford = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.