str_dup: Duplicate and concatenate strings within a character vector.

Description Usage Arguments Value Examples

Description

Vectorised over string and times.

Usage

1
str_dup(string, times)

Arguments

string

Input character vector.

times

Number of times to duplicate each string.

Value

A character vector.

Examples

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

Example output

[1] "appleapple"   "pearpear"     "bananabanana"
[1] "apple"              "pearpear"           "bananabananabanana"
[1] "ba"           "bana"         "banana"       "bananana"     "banananana"  
[6] "bananananana"

stringr documentation built on May 2, 2019, 11:03 a.m.