Learn R Programming

sdcMicro (version 3.0.0)

rankSwap: Rank Swapping

Description

Each ranked value is then swapped with another ranked value that has been chosen randomly within a restricted range.

Usage

rankSwap(data, variables, TopPercent = 5, BottomPercent = 5, K0 = -1, R0 = 0.95, P = 0, missing = -999, seed = NULL)

Arguments

data
matrix or data frame
variables
names or index of variables for that rank swapping is applied.
TopPercent
Percentage of largest values that are group together before rank swapping is applied.
BottomPercent
Percentage of lowest values that are group together before rank swapping is applied.
K0
Subset-mean preservation factor.
R0
P
missing
seed

Value

  • v

Details

Rank swapping sorts the values of one numeric variable by their numerical values (ranking). The restricted range is determined by the rank of two swapped values, which cannot differ, by definition, by more than $p$ percent of the total number of observations.

References

r

Examples

Run this code
data(testdata)
data_swap <- rankSwap(testdata,variables=c("age","income","expend","savings"))

Run the code above in your browser using DataLab