-
-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I save the group of plots produced by check_model to a figure from within a script? #674
Comments
After multiple hours, I finally checked the "see" library and figured out how to get it:
And that's it... (sorry for the post, and great work in this tool) |
After doing an update ( |
When you say it doesn't work, what exactly is happening? Can you post your script exactly so that we can look at the code? Note that when you knit an RMarkdown/Quarto script, the image files are all saved in a folder in the file directory and you can access them from there. |
I also can't figure out how to save plots to file (since I can't get them to display in my Rstudio window either). Here is some example code that tries 3 different approaches to plotting, all of which produce errors: library(lme4);
#> Loading required package: Matrix
library(performance);
fit.lmer <- lmer(Reaction ~ Days + (Days | Subject), data = sleepstudy);
### error when trying to plot in Rstudio window
check_model(fit.lmer);
#> Error: The RStudio 'Plots' window is too small to show this set of plots. You
#> may try one of the following steps to resolve this problem.
#>
#> - To fix this issue, please make the window larger.
#>
#> - If this doesn't help, try to reset your zoom settings. In RStudio, go
#> to Menu "View > Actual Size" and then retry.
#>
#> - If this still doesn't resolve your problems, you may check whether
#> your apps are rescaled. On Windows, this can be done in the display
#> settings (Start > Settings > System > Display, "Scale and layout").
#> Reduce the scaling and try again.
#>
#> - Finally, you can try to decrease the base font-size of your theme
#> before plotting. Load `library(ggplot2)` and run:
#> `theme_set(theme_classic(base_size = 6))`
### error when trying to save to png file:
png('temp.png')
check_model(fit.lmer);
#> Error: The RStudio 'Plots' window is too small to show this set of plots. You
#> may try one of the following steps to resolve this problem.
#>
#> - To fix this issue, please make the window larger.
#>
#> - If this doesn't help, try to reset your zoom settings. In RStudio, go
#> to Menu "View > Actual Size" and then retry.
#>
#> - If this still doesn't resolve your problems, you may check whether
#> your apps are rescaled. On Windows, this can be done in the display
#> settings (Start > Settings > System > Display, "Scale and layout").
#> Reduce the scaling and try again.
#>
#> - Finally, you can try to decrease the base font-size of your theme
#> before plotting. Load `library(ggplot2)` and run:
#> `theme_set(theme_classic(base_size = 6))`
dev.off();
#> quartz_off_screen
#> 2
### error when using ZaidaEMtzMo's approach
diagn_fig = plot(check_model(fit.lmer))
#> Error: The RStudio 'Plots' window is too small to show this set of plots. You
#> may try one of the following steps to resolve this problem.
#>
#> - To fix this issue, please make the window larger.
#>
#> - If this doesn't help, try to reset your zoom settings. In RStudio, go
#> to Menu "View > Actual Size" and then retry.
#>
#> - If this still doesn't resolve your problems, you may check whether
#> your apps are rescaled. On Windows, this can be done in the display
#> settings (Start > Settings > System > Display, "Scale and layout").
#> Reduce the scaling and try again.
#>
#> - Finally, you can try to decrease the base font-size of your theme
#> before plotting. Load `library(ggplot2)` and run:
#> `theme_set(theme_classic(base_size = 6))`
ggplot2::ggsave('temp.png',
plot = diagn_fig,
width = 10,
height = 15,
dpi = 300)
#> Error in eval(expr, envir, enclos): object 'diagn_fig' not found Created on 2024-06-11 with reprex v2.0.2 |
Hello,
Sorry if this is not the right place, but I have been struggling with this all day and have tried to find an answer online but I couldn't.
Your library is amazing and produces the diagnostic plots that I just need. However, I don't seem to find a way to save them.
In the terminal, when I do
check_model(analysis_model)
it produces the plots without problem, and then I can doggsave(directory, width=10,height=15,dpi=300)
and it gets saved.However, if I do that from within a script, it saves the latest figure I produced and not the one from check_model, even if I do
check_model(analysis_model)
right aboveggsave
...I have also tried:
But then I get the error:
I am sure there is a way of saving the figures from within a script, but I just can't figure it out, so I would appreciate any help.
Thank you!
The text was updated successfully, but these errors were encountered: