R/xAnd.R

Defines functions xAnd

Documented in xAnd

# insert  commas  and an  and  between the elements of a character vector  
xAnd <- function(x) {

  n <- length(x)
  lt <- x[1] 
  if (n > 1) {
    if (n > 2) for (i in 2:(n)) lt <- paste(lt, ", ", x[i], sep="")
    lt <- paste(lt, "and", x[n])
  }

  return(lt)
}

Try the lessR package in your browser

Any scripts or data that you put into this service are public.

lessR documentation built on Nov. 12, 2023, 1:08 a.m.