str_elem {filesstrings}R Documentation

Extract a single character from a string, using its index.

Description

If the element does not exist, this function returns the empty string.

Usage

str_elem(string, index)

Arguments

string

A string.

index

An integer. Negative indexing is allowed as in stringr::str_sub().

Value

A one-character string.

Examples

str_elem(c("abcd", "xyz"), 3)
str_elem("abcd", -2)

[Package filesstrings version 2.5.0 Index]