subVector | R Documentation |
Substitutes multiple patterns and corresponding replacements
subVector(x, toSub)
subMultiple(x, pattern, replacement)
x |
Vector of text to search |
toSub |
Named vector where the elements are the pattern and the names are the replacement values |
pattern |
Vector of patterns to find in each element of x |
replacement |
Vector of replacement values corresponding to each value of pattern |
Given a vector of text replaces all patterns each each element
The text in x with substitutions made
Jared P. Lander
theText <- c('Hi Bob & Cooper how is life today',
'Anything happening now?',
'Sally & Dave are playing with Jess & Julio | with their kids')
subVector(theText, toSub=c("and"='&', 'or'='\\|'))
subVector(theText)
theText <- c('Hi Bob & Cooper how is life today',
'Anything happening now?',
'Sally & Dave are playing with Jess & Julio | with their kids')
subMultiple(theText, pattern=c('&', '\\|'), replacement=c('and', 'or'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.