sdcTools / sdcMicro

sdcMicro
http://sdctools.github.io/sdcMicro/
79 stars 23 forks source link

Bug in addNoise with only one numeric key variable #305

Closed matthias-da closed 4 years ago

matthias-da commented 4 years ago

I noted this by preparing a course just now - no time to go into the code now. Most probably straightforward to solve.

library(simPop)
data(eusilcP)

sdc2 <- createSdcObj(eusilcP,  
  keyVars = c("age", "gender", "ecoStat", 
              "citizenship"), 
  numVars = "eqIncome",   
  pramVars = "region", 
  hhId = "hid"                
)
addNoise(sdc2)

Gives an error, when only one numeric key variable is selected, but at least method "additive" should work.

matthias-da commented 4 years ago

P.S. it works for other data sets. But so far, nothing seems to be wrong with eusilcP. The numeric key variable is of class numeric, thus it should also work for this data set.