str_dup {stringr} | R Documentation |
Duplicate a string
Description
str_dup()
duplicates the characters within a string, e.g.
str_dup("xy", 3)
returns "xyxyxy"
.
Usage
str_dup(string, times)
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)
str_dup(fruit, 1:3)
str_c("ba", str_dup("na", 0:5))
[Package stringr version 1.5.1 Index]