str_dup: Duplicate a string

View source: R/dup.R

str_dupR 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))

stringr documentation built on Nov. 15, 2023, 1:08 a.m.