plot_trace: Plot the trace lines of the imputation algorithm

View source: R/plot_trace.R

plot_traceR Documentation

Plot the trace lines of the imputation algorithm

Description

Plot the trace lines of the imputation algorithm

Usage

plot_trace(data, vrb = "all")

Arguments

data

An object of class mice::mids.

vrb

String, vector, or unquoted expression with variable name(s), default is "all".

Details

The vrb argument is "quoted" via rlang::enexpr() and evaluated according to tidy evaluation principles. In practice, this technical nuance only affects users when passing an object from the environment (e.g., a vector of variable names) to the vrb argument. In such cases, the object must be "unquoted" via the ⁠!!⁠ prefix operator.

Value

An object of class ggplot2::ggplot.

Examples

# create [mice::mids] object with [mice::mice()]
imp <- mice::mice(mice::nhanes, print = FALSE)

# plot trace lines for all imputed columns
plot_trace(imp)

# plot trace lines for specific columns by supplying a string or character vector
plot_trace(imp, "chl")
plot_trace(imp, c("chl", "hyp"))
# plot trace lines for specific columns by supplying unquoted variable names
plot_trace(imp, chl)
plot_trace(imp, c(chl, hyp))

# plot trace lines for specific columns by passing an object with variable names
# from the environment, unquoted with `!!`
my_variables <- c("chl", "hyp")
plot_trace(imp, !!my_variables)
# object with variable names must be unquoted with `!!`
try(plot_trace(imp, my_variables))


amices/ggmice documentation built on July 28, 2024, 5:27 p.m.