salt_replace {salty} | R Documentation |
Replace certain patterns into some values in a vector
Description
Inserts a selection of characters into some values of x. Pair salt_replace with the named vectors in replacement_shaker, or supply your own named vector of replacements. The convenience functions salt_ocr and salt_capitalization are light wrappers around salt_replace.
Usage
salt_replace(x, replacements, p = 0.1, rep_p = 0.5)
Arguments
x |
A vector. This will always be coerced to character during salting. |
replacements |
A replacement_shaker function, or a named character vector of patterns and replacements. |
p |
A number between 0 and 1. Percent of values in |
rep_p |
A number between 0 and 1. Probability that a given match should be replaced in one of the selected values. |
Value
A character vector the same length as x
Examples
x <- c("Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"Nunc finibus tortor a elit eleifend interdum.",
"Maecenas aliquam augue sit amet ultricies placerat.")
salt_replace(x, replacement_shaker$capitalization, p = 0.5, rep_p = 0.2)
salt_ocr(x, p = 1, rep_p = 0.5)
[Package salty version 0.1.0 Index]