You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm likely missing something obvious, but the plot itself doesn't appear to be a component in the returned object, so I'm having trouble accessing it to save programmatically. Any ideas?
The text was updated successfully, but these errors were encountered:
This works for saving one-off plots, but I'm still hoping to access the plot directly from the plotResiduals() object to support more complex workflows (i.e. looping through multiple predictors, saving the residual plot for each in a list, and generating a gridded figure with all the plots).
library(tidyverse)
library(lme4)
library(DHARMa)
library(here)
dat <- iris %>%
mutate(Petal.Length_factor = ifelse(Petal.Length < 4.2, "A", "B"))
mod <- lme4::lmer(Sepal.Width ~ Species + Petal.Width + (1 | Petal.Length_factor),
data = dat)
simulationOutput <- simulateResiduals(fittedModel = mod)
var <- "Petal.Width"
output_path <- here(paste0("residual_plot_", var, ".png"))
png(output_path)
plotResiduals(simulationOutput, dat %>% pull(var))
dev.off()
I'm likely missing something obvious, but the plot itself doesn't appear to be a component in the returned object, so I'm having trouble accessing it to save programmatically. Any ideas?
The text was updated successfully, but these errors were encountered: