diff --git a/R/dup.R b/R/dup.R index 2cf3ddab..3a82ffe0 100644 --- a/R/dup.R +++ b/R/dup.R @@ -11,6 +11,7 @@ #' @examples #' fruit <- c("apple", "pear", "banana") #' str_dup(fruit, 2) +#' str_dup(fruit, 2, sep = " ") #' str_dup(fruit, 1:3) #' str_c("ba", str_dup("na", 0:5)) str_dup <- function(string, times, sep = NULL) { @@ -21,7 +22,7 @@ str_dup <- function(string, times, sep = NULL) { stri_dup(input$string, input$times) } else { map_chr(seq_along(input$string), function(i) { - paste(rep(string[i], input$times[i]), collapse = sep) + paste(rep(string[[i]], input$times[[i]]), collapse = sep) }) } } diff --git a/man/str_dup.Rd b/man/str_dup.Rd index a2e2e162..48a7867b 100644 --- a/man/str_dup.Rd +++ b/man/str_dup.Rd @@ -24,6 +24,7 @@ A character vector the same length as \code{string}/\code{times}. \examples{ fruit <- c("apple", "pear", "banana") str_dup(fruit, 2) +str_dup(fruit, 2, sep = " ") str_dup(fruit, 1:3) str_c("ba", str_dup("na", 0:5)) }