You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
gglogger is an R package that logs the calls used to createggplot2 objects.
This can be useful for debugging, reproducibility, and understanding the sequence of operations used to build a plot.
Have you ever created a plot inggplot2 and then forgotten how you made it? Or wanted to reproduce a plot but couldn't remember the exact sequence of operations you used?gglogger can help!
Installation
You can install thegglogger package from source usingdevtools:
To use thegglogger package, simply load it along withggplot2 and create your plots as usual. The package will automatically log the calls used to create the plots.
# p is a ggradar plot created in the previous examplecode<-p$logs$gen_code(setup='library(dplyr)library(ggradar)mtcars_radar <- mtcars %>% as_tibble(rownames = "group") %>% mutate_at(vars(-group), scales::rescale) %>% tail(4) %>% select(1:10)')cat(code)## library(dplyr)## library(ggradar)#### mtcars_radar <- mtcars %>%## as_tibble(rownames = "group") %>%## mutate_at(vars(-group), scales::rescale) %>%## tail(4) %>%## select(1:10)###### ggradar::ggradar(mtcars_radar, legend.position = "right")# eval(parse(text = code)) # to reproduce the plot
Limitations
gglogger cannot log the global settings used to create a plot, such astheme_set(). It can only log the calls used directly to create the plot itself. You may need to manually set these global settings when reproducing a plot, or prepare them using thesetup argument ingen_code().
If your data is piped toggplot function, you need to use|> instead of%>%, otherwise the data will be logged as..
About
gglogger is an R package that logs the calls used to create ggplot2 objects.