Closed bebru closed 6 years ago
hi @bebru , thx for spotting this. could you please test with the fix i just pushed by installing sdcMicro directly from github (devtools::install_github("sdcTools/sdcMicro")
)?
Btw: option ignoreKeyVars
in extractManipData()
returns the input key-variables "as is" (eg. correct type), but you loose all possible modifications such as suppressions...
devtools::load_all()
orig <- data.frame(
a = LETTERS[1:5],
b = factor(letters[1:5]),
c = 1:5,
d= seq(0.1,0.8, length=5), stringsAsFactors = FALSE)
sdc <- createSdcObj(orig, keyVars = c("a","b","c","d"))
## just for testing introduce some NAs (could be for example from kAnon()
sdc@manipKeyVars$a[1] <- NA
sdc@manipKeyVars$b[2] <- NA
sdc@manipKeyVars$c[3] <- NA
sdc@manipKeyVars$d[4] <- NA
## with anonymisation
str(extractManipData(sdc))
'data.frame': 5 obs. of 4 variables:
$ a: chr "A" NA "C" "D" ...
$ b: Factor w/ 5 levels "a","b","c","d",..: 1 NA 3 4 5
$ c: int 1 NA 3 4 5
$ d: num 0.1 NA 0.45 0.625 0.8
## without anonymisation
str(extractManipData(sdc, ignoreKeyVars = TRUE))
'data.frame': 5 obs. of 4 variables:
$ a: chr "A" "B" "C" "D" ...
$ b: Factor w/ 5 levels "a","b","c","d",..: 1 2 3 4 5
$ c: int 1 2 3 4 5
$ d: num 0.1 0.275 0.45 0.625 0.8
Hi @bernhard-da , thanks for the (very) quick fix. Works perfectly.
Also for the hint regarding ingnoreKeyVars
. That was a rash suggestion of mine :-)
hi @bebru thx for the testing. the fix will be included in the next cran version.
If data is extracted from an sdc object with
extractManipData
, allkeyVars
are factors:This can be prevented with
ignoreKeyVars = TRUE
inextractManipData
, but it would be handier (and probably more expected) to receive the same type as the input variable is as default.