perturbation: Add Random Noise to Data

Description Usage Arguments Details Value Functions Examples

View source: R/perturbation.R

Description

Add Random Noise to Data

Usage

1
2
3
4
5
perturbation(x, cols = 1:ncol(x), magnitude = "MEDIUM", minNoise = NULL,
  maxNoise = NULL, minNoiseQuantile = NULL, maxNoiseQuantile = NULL)

randomNoise(x, cols = 1:ncol(x), magnitude = "MEDIUM", minNoise = NULL,
  maxNoise = NULL, minNoiseQuantile = NULL, maxNoiseQuantile = NULL)

Arguments

x

a data.frame

cols

the columns that are to be affected. Must be numeric. If no value is given, all columns are affected.

magnitude

a shortcut for the potential size of noise - see details

minNoise

the smallest possible value for noise that may be added. If neither minNoise nor minNoiseQuantile is provided, minNoise defaults to 0.

maxNoise

the largest possible value for noise that may be added

minNoiseQuantile

the smallest possible value for noise that may be added. Rather than an actual value, this is a decimal, representing a quantile of the values in that column. If both minNoise and minNoiseQuantile are provided, maxNoise takes priority.

maxNoiseQuantile

the largest possible value for noise that may be added. Rather than an actual value, this is a decimal, representing a quantile of the values in that column. If both maxNoise and maxNoiseQuantile are provided, maxNoise takes priority.

Details

Adds a random value between minNoise and maxNoise to each element in each of the specified columns. If minNoiseQuantile or maxNoiseQuantile is provided instead of minNoise or maxNoise, then minNoise and maxNoise are calculated for every column based on the quantiles provided. magnitude is a shortcut for minNoise and maxNoiseQuantile parameters:

This makes magnitude ideal when the user desires to have a noise value between 0 and some quantile for all specified columns.

Value

data.frame with with noise added all elements in specified columns

Functions

Examples

1
2
3
4
5
perturbation(data)
perturbation(data, 1:5)
perturbation(data, magnitude="HIGH")
perturbation(data, "Gender", minNoise = 10, maxNoise = 50)
perturbation(data, minNoiseQuantile = .1, maxNoise = .9)

shuklak13/anonymizeR documentation built on May 29, 2019, 9:27 p.m.