Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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

A character vector.

Examples

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

stringr

Simple, Consistent Wrappers for Common String Operations

v1.4.0
GPL-2 | file LICENSE
Authors
Hadley Wickham [aut, cre, cph], RStudio [cph, fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.