#' Make Sentance
#'
#' Compress atomic vector into a sentence.
#' @param x Atomic vector
#' @export
#' @return Sentence
#' @examples
#' makeSentence(x = c('red', 'yellow', 'blue'))
makeSentence <- function(x){
if (length(x) == 1){
return(x)
}else if (length(x) == 2){
return(paste(x, collapse = ' and '))
}else{
return(
paste0(
paste(saxy::allbutlast(x), collapse = ', '),
paste0(', and ', saxy::last(x))
)
)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.