Use png and dev.off instead of ggsave.

ggsave is a bit jankier and you have much less control.
Do a bit of manual memory optimization.

Also add a bit of logging so you can monitor progress of
script