Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

swap

Swap Two Patterns Simultaneously


Description

Swap pattern x for pattern y and pattern y for pattern x in one fell swoop.

Usage

swap(x, pattern1, pattern2, ...)

Arguments

x

A text variable.

pattern1

Character string to be matched in the given character vector. This will be replaced by pattern2.

pattern2

Character string to be matched in the given character vector. This will be replaced by pattern1.

...

ignored.

Value

Returns a vector with patterns 1 & 2 swapped.

Examples

x <- c("hash_abbreviation", "hash_contractions", "hash_grade", "key_emoticons", 
    "key_power", "key_sentiment", "key_sentiment_nrc", "key_strength", 
    "key_syllable", "key_valence_shifters")

x
swap(x, 'hash_', 'key_')

textclean

Text Cleaning Tools

v0.9.3
GPL-2
Authors
Tyler Rinker [aut, cre], ctwheels StackOverflow [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.