scoped-impute_median | R Documentation |
impute_median
impute_median
imputes the median for a vector. To only impute many
variables at once, we recommend that you use the across
function
workflow, shown in the examples for impute_median()
. You can use the
scoped variants, impute_median_all
.impute_below_at
, and
impute_below_if
to impute all, some, or just those variables meeting
some condition, respectively. To use _at
effectively, you must know
that _at
affects variables selected with a character vector, or with
vars()
.
impute_median_all(.tbl)
impute_median_at(.tbl, .vars)
impute_median_if(.tbl, .predicate)
.tbl |
a data.frame |
.vars |
variables to impute |
.predicate |
variables to impute |
an dataset with values imputed
# select variables starting with a particular string.
impute_median_all(airquality)
impute_median_at(airquality,
.vars = c("Ozone", "Solar.R"))
library(dplyr)
impute_median_at(airquality,
.vars = vars(Ozone))
impute_median_if(airquality,
.predicate = is.numeric)
library(ggplot2)
airquality %>%
bind_shadow() %>%
impute_median_all() %>%
add_label_shadow() %>%
ggplot(aes(x = Ozone,
y = Solar.R,
colour = any_missing)) +
geom_point()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.