str_dup()
duplicates the characters within a string, e.g.
str_dup("xy", 3)
returns "xyxyxy"
.
Arguments
- string
Input vector. Either a character vector, or something
coercible to one.
- times
Number of times to duplicate each string.
Value
A character vector the same length as string
/times
.
Examples
fruit <- c("apple", "pear", "banana")
str_dup(fruit, 2)
#> [1] "appleapple" "pearpear" "bananabanana"
str_dup(fruit, 1:3)
#> [1] "apple" "pearpear" "bananabananabanana"
str_c("ba", str_dup("na", 0:5))
#> [1] "ba" "bana" "banana" "bananana"
#> [5] "banananana" "bananananana"