partial_permut: Get partial permutation of a vector

View source: R/operations.R

partial_permutR Documentation

Get partial permutation of a vector

Description

Get partial permutation of a vector

Usage

partial_permut(x, exp_sim = 0)

Arguments

x

a vector with at least 2 elements

exp_sim

a value between 0 and 1 indicating the level of expected similarity between the input and output vector. Default value is 0 (random permutation).

Value

a partially (random) permutated vector. If exp_sim = 0 then the result is equal to sample(x) (a random permutation). If exp_sim = 1 then the result is always the same as the input vector. For exp_sim values between 0 and 1 we randomly sample a subset of the input vector inversely proportionate to the exp_sim value (e.g. exp_sim = 0.8 => 20% of the elements) and randomly permutate these elements only.

Examples

set.seed(42)
partial_permut(x = LETTERS, exp_sim = 0)
partial_permut(x = LETTERS, exp_sim = 0.5)
partial_permut(x = LETTERS, exp_sim = 0.9)


usefun documentation built on Sept. 15, 2024, 1:06 a.m.