strrep
Expand the Strings in Character Vector by Repetition

Description

Replaces strings with a repeated version of themselves.

Usage

strrep(x, times)

Arguments

x a character vector, or another data type that can be converted to a character vector with as.character(x).
times a vector of nonnegative integers.
Value
returns a character vector as long as the longest of x and times, or of length zero if either argument has length zero. The ith element of the output will be the ith element of x repeated times[i] times.
Examples
strrep(c("AB", "CDE", "FG"), c(3,2,0))
strrep(c("xy", "uvw"), 3)
cat(sep="\n", paste0(strrep("  ", c(0,1,2,2,1)),
    c("Topics", "Topic A", "Subtopic A1", "Subtopic A2", "Topic B")))
Package base version 6.1.4-13
Package Index