salt_swap: Randomly swap out entire values in a vector

Description Usage Arguments Value Examples

View source: R/salt_swap.R

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

1
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

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.")

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

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

mdlincoln/salty documentation built on May 20, 2019, 9:59 a.m.