This function exports a ggplot2 figure to a given path. It exports both an archived version with the current date and a current version without a date. The function supports exporting to PDF and JPG formats.

ama_export_fig(figure, filename, filepath, width = 7, height = 7)

Arguments

figure

A ggplot2 object.

filename

A character string specifying the filename without the extension.

filepath

A character string specifying the directory to save the file.

width

The width of the image in inches (default is 7 inches).

height

The height of the image in inches (default is 7 inches).

Examples

if (FALSE) {
test_plot <- ggplot(mpg, aes(x=displ, y=hwy)) + geom_point()  # Create a ggplot2 plot
filename <- "sample_plot"  # Define a filename
filepath <- tempdir()  # Define a path using a temporary directory
ama_export_fig(test_plot, filename, filepath)  # Call the ama_export_fig function
}