salty (version 0.1.0)

salt_swap: Randomly swap out entire values in a vector

Description

Because swaps can be provided by either a character vector or a function that returns a character vector, salt_swap can be fruitfully used in conjunction with the charlatan::charlatan package to intersperse real data with simulated data.

Usage

salt_swap(x, swaps, p = 0.2)

Arguments

x

A vector. This will always be coerced to character during salting.

swaps

Values to be swapped out

p

A number between 0 and 1. Percent of values in x that should be salted.

Value

A character vector the same length as x

Examples

Run this code
# NOT RUN {
x <- c("Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
       "Nunc finibus tortor a elit eleifend interdum.",
       "Maecenas aliquam augue sit amet ultricies placerat.")

new_values <- c("foo", "bar", "baz")

salt_swap(x, swaps = new_values, p = 0.5)
# }

Run the code above in your browser using DataLab