Opens a graphics device chosen from the file extension (.pdf,
.svg, .png, .tiff, .jpeg), evaluates expr so whatever it
draws lands on that device, and closes the device. expr is lazily
evaluated, so a call like save_bayesqm_plot("fig.pdf", plot(fit))
does not draw to the current screen device first. If expr returns
a ggplot object (for example, from ggplot2::autoplot()), it is
print()ed onto the device.
Examples
fit <- demo_fit(N = 6, J = 10, K = 2, Td = 50, seed = 1)
f <- file.path(tempdir(), "fig_loadings.pdf")
save_bayesqm_plot(f, plot_loading_posterior(fit))
unlink(f)