library(ggplot2)
## create ggfigdone database in a temporary directory
db_dir = file.path(tempdir(), "fd_unique")
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", fdObj = fo)
## Add the another figure with the same name
fd_add(g = g + theme_classic(), name = "fig1", fdObj = fo)
## Keep the figure with the latest created date
fd_unique(fdObj = fo, by = "created_date")
## Show the updated ggfigdone database
print(fo)
Run the code above in your browser using DataLab