Learn R Programming

anonymizer (version 0.2.0)

unsalt: Unsalt a vector.

Description

salt takes a vector .x and returns an unsalted version of it. The algorithm for unsalting a vector is:
  1. Select a random sample of characters of length .n_chars from .chars. Call this random sample .y.
  2. Substitute .y out of the vector .x wherever it occurs, in a vectorized fashion.

Usage

unsalt(.x, .seed = NULL, .chars = letters, .n_chars = 5L)

Arguments

.x
a vector.
.seed
an integer to seed the random number generator.
.chars
set of characters to unsalt with.
.n_chars
an integer; number of characters to unsalt with.

Value

An unsalted version of the vector.

Details

The user is advised to check out Wikipedia for more information.

Examples

Run this code
# Use various number of characters
unsalt(salt(letters, .n_chars = 0L))
unsalt(salt(letters, .n_chars = 1L))
unsalt(salt(letters, .n_chars = 5L))
unsalt(salt(letters))

# Use other sets of characters to salt with
unsalt(salt(letters, .chars = letters[1:2]), .chars = letters[1:2])

Run the code above in your browser using DataLab