rep2: Repeat something with the ability to also collapse the...

View source: R/rep2.R

rep2R Documentation

Repeat something with the ability to also collapse the output.

Description

Repeat something with the ability to also collapse the output. The base 'rep("ha", 3)' function does not support arguments like 'collapse' or 'sep' like 'paste(...)'. 'rep2' closes this gap.

Usage

rep2(x, n, ...)

Arguments

x

The object to repeat

n

The amount how often the object should be repeated

...

Further arguments passed to 'paste' (see 'help("paste")' for more information).

Value

The result from 'paste(rep(x, n), sep = sep, collapse = collapse)'

Examples

  ## rep2 is the same like rep:
  rep(x = "ha", 3)
  #> "ha" "ha" "ha"
  rep2(x = "ha", 3)
  #> "ha" "ha" "ha"

  ## ... but you can also use the arguments from `paste`:
  rep2(x = "ha", n = 3, collapse = "")
  #> "hahaha"


DIZtools documentation built on Sept. 18, 2023, 9:07 a.m.