Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
shadow_shift handling infinite values #90
The handling of infinite values currently returns NaN - it should ideally return a shifted missing value and issue a warning for handling infinite values (ideally they should not be in your dataset, right?)
There should also be some way of turning off this behaviour / the loud noise that it makes
Below is some testing code for handling this.
library(naniar) df_inf <- data.frame(x = c(-Inf,rnorm(2), NA, Inf)) df_inf df_inf %>% add_shadow_shift(x) # use the minimum for the non infinite values xmin <- min(df_inf$x[!is.infinite(df_inf$x)], na.rm = TRUE) x_shift <- xmin - xmin*0.1 # set the seed here # set.seed(seed_shift) x_jitter <- (stats::runif(length(df_inf$x))-0.50)*x_shift*0.10 ifelse(is.na(df_inf$x), yes = x_shift + x_jitter, no = df_inf$x)