strrep

0th

Percentile

Repeat the Elements of a Character Vector

Repeat the character strings in a character vector a given number of times (i.e., concatenate the respective numbers of copies of the strings).

Keywords
character
Usage
strrep(x, times)
Arguments
x
a character vector, or an object which can be coerced to a character vector using as.character.
times
an integer vector giving the (non-negative) numbers of times to repeat the respective elements of x.
Details

The elements of x and times will be recycled as necessary (if one has no elements, and empty character vector is returned). Missing elements in x or times result in missing elements of the return value.

Value

A character vector with the elements of the given character vector repeated the given numbers of times.

Aliases
  • strrep
Examples
library(base) strrep("ABC", 2) strrep(c("A", "B", "C"), 1 : 3) ## Create vectors with the given numbers of spaces: strrep(" ", 1 : 5)
Documentation reproduced from package base, version 3.3, License: Part of R @VERSION@

Community examples

Looks like there are no examples yet.