rOpenSci | How to Save ggplot2 Plots in a targets Workflow?

I really enjoy using targets for all of my data analysis projects, especially because it helps me structure all of the projects nicely in the same folder. For targets projects, I often produce several figures using ggplot2. However, there are no formal recommendations for saving ggplot2 objects (as opposed to static images) in a targets workflow.


This is a companion discussion topic for the original entry at https://ropensci.org/blog/2022/12/06/save-ggplot2-targets/

Hi, thanks @Rekyt for this illuminating blog post! I was wondering if your recommendations would change two years later? Especially when using targets within Quarto projects for instance? I have found in such projects, we need the flexibility of ggplot2 objects, but printing these large plots for each rendering is quite time-consuming (even when printing complex plot with targets::tar_read()).

I would very much like your opinion and feedback from experience on this (and anyone else of course).

Best regards,

Hi @cpauvert,
I realize that I never answered you!

I still think that what’s written in this blogpost still holds true, because ggplot2 still saves the entire environmet.

I don’t know about your specific use case because in my workflows I’m reluctant on using Quarto for now, so I’m still working with targets workflows with some Rmarkdown documents within them.

Maybe you could develop your use case or show an example?