sdcTools / sdcMicro

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

Update if(nrow(risk)>0) in recordSwap #330

Closed Kyoshido closed 2 years ago

Kyoshido commented 2 years ago

Because of this command risk <- data.table(risk) the matrix is always converted into the data.table So then the check of numeric values any(!is.numeric(risk)) always fails. So I repaired it.

Doesn't work

any(!is.numeric(risk))
[1] TRUE
is.numeric(risk)
[1] FALSE

Individualy numeric is ok

is.numeric(risk$V1)
[1] TRUE
is.numeric(risk$V2)
[1] TRUE

My solution

unlist(lapply(risk, is.numeric))
  V1   V2 
TRUE TRUE 

any(!unlist(lapply(risk, is.numeric)))
[1] FALSE
bernhard-da commented 2 years ago

@Kyoshido thx Jiří for spotting this;