sdcTools / sdcMicro

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

Error message if using k-anonimity in sdcApp #270

Closed thijsbenschop closed 5 years ago

thijsbenschop commented 5 years ago

While looking into issue #269, I noticed that every time the k-anonimity page is opened in sdcApp(), the following error is shown in the R console:

schermafbeelding 2018-11-23 om 13 51 48

The reason is the evaluation of the condition in line 440 of ui_categorical.R:

if (input$rb_kanon_useCombs=="Yes" & (!is.null(pp) && length(pp$use)==0)) {

Initially, input$rb_kanon_useCombs is "No", but nevertheless the second part of the condition is also evaluated. However, pp is, probably due to the change in Shiny, no longer NULL. In fact, is.null(pp) returns

schermafbeelding 2018-11-23 om 14 44 44

Probably, because cn1 in line 291

cn1 <- cn[grep("rb_kanon_usecombs_", cn)]

is no longer of length 0 (class is character).

A simple way to fix this would be to use a double & in line 440:

if (input$rb_kanon_useCombs=="Yes" && (!is.null(pp) && length(pp$use)==0)) {

In that way, the second part isn't evaluated if input$rb_kanon_useCombs is "No".

This warning/error can be reproduced with any dataset and specifying a few categorical key variables. Then going to k-Anonimity on the Anonymize tab will briefly show the error on the screen as well as permanently in the R console.

bernhard-da commented 5 years ago

@thijsbenschop thx for reporting