Learn R Programming

stringr (version 0.6.2)

str_dup: Duplicate and concatenate strings within a character vector.

Description

Vectorised over string and times.

Usage

str_dup(string, times)

Arguments

string
input character vector
times
number of times to duplicate each string

Value

  • character vector

Examples

Run this code
fruit <- c("apple", "pear", "banana")
str_dup(fruit, 2)
str_dup(fruit, 1:3)
str_c("ba", str_dup("na", 0:5))

Run the code above in your browser using DataLab