CORE-forge / coresoi

R package for CORE set of indicators
https://core-forge.github.io/coresoi/
MIT License
13 stars 1 forks source link

Test with case_when #31

Closed simonedelsa closed 1 year ago

simonedelsa commented 1 year ago

Performing ks test with a condition (e.g., case_when) does not run. See part of the (new) code for indicator 2 below:

[...]
      test = dplyr::case_when(
        npre > 0 & npost == 0 ~ 1, # not at risk, pvalue=1
        npre == 0 & npost > 0 ~ 0, # at risk, pvalue=0
        # npre > 0 & npost > 0 ~ test(var = {{ contract_value }}, group = prepost, data = ., test_type)[1],
        TRUE ~ test(var = {{ contract_value }}, group = prepost, data = ., test_type)[1]
      )

It seems that the condition is not checked and "test" function has been ran anyway, thus detecting an error (prepost with only one level)

PS: for the moment, it is fixed by including an "if" within "test" function (if group has only one level, then skip)

NiccoloSalvini commented 1 year ago

solved in 3ab9ae7 + 8ec8ca0!