library(ggplot2)
## Initial ggfigdone database using `fd_init`
db_dir = file.path(tempdir(), "fd_add_exp")
fo = fd_init(db_dir, rm_exist = TRUE)
## Draw a ggplot figure
g = ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point()
## Add the figure to the database
fd_add(g = g, name = "fig1", fo)
## Add the same figure with a different name
fd_add(g = g, name = "fig2", fo)
## Show the updated ggfigdone database
print(fo)
Run the code above in your browser using DataLab