Recently I have came across the package validate in R which is very useful when you want to validate a full data set with pre-defined rules, say for example:
v <- validator(
Species.na = !is.na(Species),
Species.range = Species %in% c("setosa", "versicolor", "virginica"),
Sepal.Width.na = !is.na(Sepal.Width),
Sepal.Width.range = Sepal.Width >= 2 & Sepal.Width <= 4,
Sepal.Length.relation = Sepal.Length/Petal.Length < 4)
valied <- confront(iris, v)
Now I was wondering if something similar is available with missing value imputation. There are packages like mice, mi etc. which are really nice but imputation methods are standard, not user defined or custom. Can anyone suggest if there is anyway to set some pre-defined missing functions and apply them to a R data.frame. Something which could work like :
m <- missing(
Species.na = if(is.na(Species)) Species <- "setosa"
Sepal.Width.na = if(is.na(Sepal.Width)) Sepal.Width <- 3.5)
mi <- confront(iris, m)