R/collapse.R

Defines functions collapse

Documented in collapse

#' Collapse vector to string.
#'
#' A simple wrapper for \code{paste(x, collapse)}.
#'
#' @param x [\code{vector}]\cr
#'   Vector to collapse.
#' @param sep [\code{character(1)}]\cr
#'   Passed to \code{collapse} in \code{\link{paste}}.
#'   Default is \dQuote{,}.
#' @return [\code{character(1)}].
#' @export
#' @examples
#' collapse(c("foo", "bar"))
#' collapse(c("foo", "bar"), sep = ";")
collapse = function(x, sep = ",") {
  paste0(x, collapse = sep)
}

Try the BBmisc package in your browser

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

BBmisc documentation built on Sept. 29, 2022, 5:12 p.m.