You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This builds off of #197 - it's roughly the same idea, but I think it's useful to express imputed as it's own method and then build components off of that.
The general idea would be to build a basic vector level function / S3 methods to identify whether a value has been imputed.
These could be done for just regular numeric/integer/factor/classes. This could then be done for shade class and co
library(naniar)
vec<-1:5vec[c(2, 4)] <-NAvec#> [1] 1 NA 3 NA 5vec_imputed<- impute_fixed(vec, 0)
vec_imputed#> [1] 1 0 3 0 5imputed<-function(x, ...){
UseMethod("imputed")
}
is.na(vec) ==!is.na(vec_imputed)
#> [1] FALSE TRUE FALSE TRUE FALSEimputed.numeric<-function(x, y, ...){
x_na<- is.na(x)
y_complete<-!is.na(y)
which_imputed<-x_na==y_completewhich_imputed
}
imputed(vec, vec_imputed)
#> [1] FALSE TRUE FALSE TRUE FALSE# what if only one number is imputed?vec2<-1:3vec2[1:2] <-NAvec2#> [1] NA NA 3vec2_imputed<-vec2vec2_imputed[1] <-0vec2_imputed#> [1] 0 NA 3
imputed(vec2, vec2_imputed)
#> [1] TRUE FALSE FALSE
Note that imputed will also need to do double dispatch, to account for shade being a possible second class so I'll probably need to wrap shade up properly in a vctrs class: https://vctrs.r-lib.org/articles/s3-vector.html as well as implement imputed as a new class.
Overall this adds more complexity to the package but should help users identify imputations and do more with them. Hopefully!
The text was updated successfully, but these errors were encountered:
This builds off of #197 - it's roughly the same idea, but I think it's useful to express
imputed
as it's own method and then build components off of that.The general idea would be to build a basic vector level function / S3 methods to identify whether a value has been imputed.
These could be done for just regular numeric/integer/factor/classes. This could then be done for
shade
class and coCreated on 2024-03-10 with reprex v2.1.0
Session info
Note that
imputed
will also need to do double dispatch, to account forshade
being a possible second class so I'll probably need to wrapshade
up properly in avctrs
class: https://vctrs.r-lib.org/articles/s3-vector.html as well as implementimputed
as a new class.Overall this adds more complexity to the package but should help users identify imputations and do more with them. Hopefully!
The text was updated successfully, but these errors were encountered: