mystr_detect_replace: Detect substring and replace if there is a match

Description Usage Arguments Value

View source: R/rtools.R

Description

Replaces elements in character vector 'string' with elements found in 'replacement', if the element matches one of the patterns in 'pattern'. Matches of pattern[i] are replaced with replacement[i].

Intended usage is to convert a vector of path strings into a vector of class labels.

Usage

1
mystr_detect_replace(string, pattern, replacement = pattern)

Arguments

string

Input vector. Either a character vector, or something coercible to one.

pattern

Vector of patterns to look for. See stringr::str_which() for details.

replacement

Vector of replacement strings. Has to be of the same length as pattern.

Value

A character vector.


jutako/Rtools documentation built on May 29, 2019, 4:52 p.m.