library(dplyr)
vec <- rnorm(10)
vec[sample(1:10, 3)] <- NA
impute_below(vec)
impute_below(vec, prop_below = 0.25)
impute_below(vec,
prop_below = 0.25,
jitter = 0.2)
dat <- tibble(
num = rnorm(10),
int = as.integer(rpois(10, 5)),
fct = factor(LETTERS[1:10])
) %>%
mutate(
across(
everything(),
\(x) set_prop_miss(x, prop = 0.25)
)
)
dat
dat %>%
nabular() %>%
mutate(
num = impute_below(num),
int = impute_below(int),
fct = impute_below(fct),
)
dat %>%
nabular() %>%
mutate(
across(
where(is.numeric),
impute_below
)
)
dat %>%
nabular() %>%
mutate(
across(
c("num", "int"),
impute_below
)
)
Run the code above in your browser using DataLab