shuffle: Shuffle list of data sets

View source: R/shuffle.R

shuffleR Documentation

Shuffle list of data sets

Description

Shuffles the rows in a list of synthetic data sets

Usage

shuffle(data)

Arguments

data

list of synthetic data sets as returned by extract (or similar).

Details

This function shuffles the rows of a list of synthetic data sets and removes row names in the process. This is intended to provide an additional layer of protection and (identification) disclosure attempts.

See also compute.risk and replace.high.risk for disclosure risk computation.

Value

An object of class robosynth.list (a list of data frames).

Author(s)

Simon Grund

See Also

extract, compute.risk, replace.high.risk

Examples

# create masked copies
sociosexuality <- within(sociosexuality, {

  m_sex <- mask.categorical(sex, probability = .80)
  m_sexpref <- mask.categorical(sexpref, probability = .60)
  m_age <- mask.continuous(age, reliability = .90)

})

# combine synthesis and masking models
models <- combine.models(

  synthesis.model(sex ~ 1, type = "binary"),
  synthesis.model(sexpref ~ 1 + sex, type = "categorical"),
  synthesis.model(age ~ 1 + sex + sexpref, type = "continuous"),

  masking.model(m_sex ~ sex, type = "binary"),
  masking.model(m_sexpref ~ sexpref, type = "categorical"),
  masking.model(m_age ~ age, type = "continuous"),

  data = sociosexuality

)

# run synthesis
syn <- synthesize(models = models, m = 5, iter = 5)

# extract list of synthetic data sets
synlist <- extract(syn)

# shuffle rows
synlist <- shuffle(synlist)

simongrund1/robosynth documentation built on March 20, 2022, 6:15 p.m.