File: strrepeat.R

package info (click to toggle)
r-cran-bbmisc 1.13.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,256 kB
  • sloc: ansic: 176; sh: 9; makefile: 5
file content (18 lines) | stat: -rw-r--r-- 498 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#' @title Repeat and join a string
#'
#' @description
#' Repeats a string n times and joins the results.
#'
#' @param x [character]\cr
#'   Vector of characters.
#' @param n [\code{integer(1)}]\cr
#'   Times the vector \code{x} is repeated.
#' @param sep [\code{character(1)}]\cr
#'   Separator to use to collapse the vector of characters.
#' @return \code{character(1)}.
#' @export
#' @examples
#' strrepeat("x", 3)
strrepeat = function(x, n, sep = "") {
  paste0(rep.int(x, n), collapse = sep)
}