impute_below | R Documentation |
It can be useful in exploratory graphics to impute data outside the range of
the data. impute_below
imputes variables with missings to have values
10 percent below the range for numeric values, plus some jittered noise,
to separate repeated values, so that missing values can be visualised
along with the rest of the data. For character or factor
values, it adds a new string or label.
impute_below(x, ...)
x |
a variable of interest to shift |
... |
extra arguments to pass |
add_shadow_shift()
cast_shadow_shift()
cast_shadow_shift_label()
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
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.