Title: | Track 'ggplot2' Calls |
---|---|
Description: | Provides a way to log 'ggplot' component calls, which can be useful for debugging and understanding how 'ggplot' objects are created. The logged calls can be printed, saved, and re-executed to reproduce the original 'ggplot' object. |
Authors: | Panwen Wang [aut, cre] |
Maintainer: | Panwen Wang <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.5 |
Built: | 2024-10-26 07:19:17 UTC |
Source: | https://github.com/pwwang/gglogger |
Override + operator for ggplot objects to log calls
## S3 method for class 'gg' e1 + e2
## S3 method for class 'gg' e1 + e2
e1 |
A ggplot object. |
e2 |
A layer to add to the ggplot object. |
A ggplot object with logged calls.
The 'GGLog' class is used to store a single ggplot call.
code
A string to store the code of the ggplot call.
evaluate(envir = parent.frame())
Evaluate the log.
@param envir The environment to evaluate the log in.
stringify()
Stringify the log.
@return A string.
The 'GGLogs' class is used to store logs of ggplot calls. Each log is stored as a 'GGLog' object. The object can be accessed using the '$logs' field from a ggplot object.
logs
A list to store the logs.
add(log)
Add a log to the list.
@param log A GGLog object.
evaluate(envir = parent.frame())
Evaluate all logs in the list.
@param envir The environment to evaluate the logs in.
gen_code(setup = "library(ggplot2)")
Generate code for all logs in the list.
@param setup A string to setup the environment.
@return A string of code.
stringify()
Stringify all logs in the list.
@return A string.
Override ggplot function to log calls
ggplot(...)
ggplot(...)
... |
Arguments passed to ggplot2::ggplot. |
A ggplot object with logged calls.
Print a GGLog object
## S3 method for class 'GGLog' print(x, ...)
## S3 method for class 'GGLog' print(x, ...)
x |
A GGLog object. |
... |
Additional arguments. |
Display the logs and invisibly return the logs.
Print a GGLogs object
## S3 method for class 'GGLogs' print(x, ...)
## S3 method for class 'GGLogs' print(x, ...)
x |
A GGLogs object. |
... |
Additional arguments. |
Display the logs and invisibly return the logs.
Register a function that returns a ggplot object This is usually implemented by ggplot extensions.
register(f, name = NULL)
register(f, name = NULL)
f |
A function that returns a ggplot object. |
name |
A string to represent the name of the function. |
A function that returns a ggplot object with logged calls.