sdcTools / sdcMicro

sdcMicro
http://sdctools.github.io/sdcMicro/
78 stars 22 forks source link

Vector for importance kAnon too long #269

Closed thijsbenschop closed 5 years ago

thijsbenschop commented 5 years ago

Hi,

in line 270 of ui_categorical.R, the list of variables for the importance vector is loaded to test whether all key variables were specified.

cn <- names(input)[grep("sel_importance_", names(input))]

However, the vector cnis twice as long as the number of categorical key variables, since there exists in input for each variable input$selimportance# and input$selimportance#_selectized.

For this reason, the condition in line 442 can never be fulfilled

if (kAnon_useImportance() && any(impvec=="")) {

and as a result the blue apply button will never appear.

A solution would be to add

cn <- cn[which(!grepl("ctiz", cn))]

to remove the variable names with the suffix "_selectized".

It's not clear to me where these variables with suffix "_selectized" are generated and it seems not to happen in all instances.

I tested this on Mac OS X with R3.5.1 and sdcMicro 5.3.0.

bernhard-da commented 5 years ago

@thijsbenschop please provide a reproducable example.

mwelch750 commented 5 years ago

Hi Thijs, I am not at my computer now, but I used our CaseA dataset when I got this error on my windows machine, R3.5.1. Perhaps you can share an example using that. I had 6 keys in my example.

Sent from my iPhone

On Nov 13, 2018, at 15:59, thijsbenschop notifications@github.com wrote:

Hi,

in line 270 of ui_categorical.R, the list of variables for the importance vector is loaded to test whether all key variables were specified.

cn <- names(input)[grep("selimportance", names(input))]

However, the list cnis twice as long as the number of categorical key variables, since there exists in input for each variable input$selimportance# and input$selimportance#_selectized.

For this reason, the condition in line 442 can never be fulfilled

if (kAnon_useImportance() && any(impvec=="")) {

and as a result the blue apply button will never appear.

A solution would be to add

cn <- cn[which(!grepl("ctiz", cn))]

to remove the variable names with the suffix "_selectized".

It's not clear to me where these variables with suffix "_selectized" are generated and it seems not to happen in all instances.

I tested this on Mac OS X with R3.5.1 and sdcMicro 5.3.0.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

thijsbenschop commented 5 years ago

@bernhard-da, thank you for your quick response. I get this with any dataset when using categorical key variables and applying local suppression with an importance vector. For example:

1) load testdata 2) select roof, walls and water as cat. key variables 3) go to k-Anonimity and set "Do you want to modify importance of key variables for suppression?" to "Yes". Now the blue button will disappear, as it is supposed to. 4) Select the importance of the three key variables (1,2,3). The button doesn't reappear.

After digging into this a little deeper, it turned out that impvec always has some empty strings, as its length is twice the number of key variables. Therefore, the above condition isn't fulfilled.

thijsbenschop commented 5 years ago

OS and versions as specified above.

bernhard-da commented 5 years ago

@thijsbenschop @mwelch750 this was due to a update in shiny. thx for spotting and reporting

thijsbenschop commented 5 years ago

@bernhard-da, thanks for fixing