Learn R Programming

anonymizer (version 0.2.0)

salt: Salt a vector.

Description

salt takes a vector .x and returns a salted version of it. The algorithm for salting a vector is:
  1. Select a random sample of characters of length .n_chars from .chars. Call this random sample .y.
  2. Concatenate .y, the vector .x, and .y again in a vectorized fashion.

Usage

salt(.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 salt with.
.n_chars
an integer; number of characters to salt with.

Value

A salted 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
salt(letters, .n_chars = 0L)
salt(letters, .n_chars = 1L)
salt(letters, .n_chars = 5L)
salt(letters)

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

Run the code above in your browser using DataLab