# NOT RUN {
# small function to display plots only if it's interactive
p_ <- GGally::print_if_interactive
data(mtcars)
# use mtcars dataset and alter the 'am' column to display actual name values
mtc <- mtcars
mtc$am <- c("0" = "automatic", "1" = "manual")[as.character(mtc$am)]
# step the complete model down to a smaller model
mod <- stats::step(stats::lm(mpg ~ ., data = mtc), trace = FALSE)
# display using defaults
pm <- ggnostic(mod)
p_(pm)
# color by am value
pm <- ggnostic(mod, mapping = ggplot2::aes(color = am))
p_(pm)
# turn resid smooth error ribbon off
pm <- ggnostic(mod, continuous = list(.resid = wrap("nostic_resid", se = FALSE)))
p_(pm)
## plot residuals vs fitted in a ggpairs plot matrix
dt <- broomify(mod)
pm <- ggpairs(
dt, c(".fitted", ".resid"),
columnLabels = c("fitted", "residuals"),
lower = list(continuous = ggally_nostic_resid)
)
p_(pm)
# }
Run the code above in your browser using DataLab