%regex=% | R Documentation |
This takes two arguments just like gsub
- a patterns and a replacement.
It will only overwrite the parts of any character where the pattern is matched with the second argument.
If you want to overwrite whole elements via a regex (i.e. replace the entire element if it matches),
use %regex<-%
instead.
x %regex=% value
x |
a character vector |
value |
c(pattern, replacement) |
Ben Wiseman, benjamin.wiseman@kornferry.com
# Apply a regular expression/substitution to x:
x <- c("a1b", "b1", "c", "d0")
# change any number to "x"
x %regex=% c("\\d+", "x")
print(x)
# "axb" "b" "c" "dx"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.