Skip to content

impute_lr in combination with validator  #2

@smartie5

Description

@smartie5

I have some questions concerning the use of deductive in combination with validate. Here is what I tried:
library(validate) (version 0.2.6)
library(deductive) (version 0.1.2)
dat <- data.frame(a=NA, b=NA, c=5, d=5)
rules <- validator(var_group(a,b,c,d) >= 0, a+b+c==d)
impute_lr(dat, rules)

Here NAs remain NAs. Using rules2 <- validator(a >= 0, b >= 0, c >= 0, d >= 0, a+b+c==d) impute_lr(dat, rules2) instead of rules gives the result I expected. Why isn't the validator with var_group working the same way?

Imputing this dataframe gives an undesired result as well:
dat2 <- data.frame(a=NA, b=NA, c=10, d=9)
impute_lr(dat2, rules2)
In my opinion leaving NA in this case would be better than imputing values which fail the editrules.

In my case using sum inside the validator function would be a benefit like
rules3 <- validator(a >= 0, b >= 0, c >= 0, d >= 0, sum(a,b,c, na.rm=T) == d)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions