salt_replace: Replace certain patterns into some values in a vector

Description Usage Arguments Value Examples

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

1
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 x that should be salted.

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

1
2
3
4
5
6
7
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)

salty documentation built on May 2, 2019, 9:33 a.m.