str_paste_elems: Extract single elements of a string and paste them together.

View source: R/elem.R

str_paste_elemsR Documentation

Extract single elements of a string and paste them together.

Description

This is a quick way around doing a call to str_elems() followed by a call of apply(..., paste).

Usage

str_paste_elems(string, indices, sep = "")

Arguments

string

A character vector.

indices

A vector of integerish values. Negative indexing is allowed as in stringr::str_sub().

sep

A string. The separator for pasting string elements together.

Details

Elements that don't exist e.g. element 5 of "abc" are ignored.

Value

A character vector.

See Also

Other single element extractors: str_elems(), str_elem()

Examples

string <- c("abc", "def", "ghi", "vwxyz")
str_paste_elems(string, 1:2)
str_paste_elems(string, c(1, 2, 3, 4, -1))
str_paste_elems("abc", c(1, 5, 55, 43, 3))

strex documentation built on Nov. 2, 2023, 6:04 p.m.