Package 'gglogger'

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

Help Index


Override + operator for ggplot objects to log calls

Description

Override + operator for ggplot objects to log calls

Usage

## S3 method for class 'gg'
e1 + e2

Arguments

e1

A ggplot object.

e2

A layer to add to the ggplot object.

Value

A ggplot object with logged calls.


GGLog class

Description

The 'GGLog' class is used to store a single ggplot call.

Fields

code

A string to store the code of the ggplot call.

Methods

evaluate(envir = parent.frame())

Evaluate the log.

@param envir The environment to evaluate the log in.

stringify()

Stringify the log.

@return A string.


GGLogs class

Description

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.

Fields

logs

A list to store the logs.

Methods

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

Description

Override ggplot function to log calls

Usage

ggplot(...)

Arguments

...

Arguments passed to ggplot2::ggplot.

Value

A ggplot object with logged calls.


Print a GGLog object

Description

Print a GGLog object

Usage

## S3 method for class 'GGLog'
print(x, ...)

Arguments

x

A GGLog object.

...

Additional arguments.

Value

Display the logs and invisibly return the logs.


Print a GGLogs object

Description

Print a GGLogs object

Usage

## S3 method for class 'GGLogs'
print(x, ...)

Arguments

x

A GGLogs object.

...

Additional arguments.

Value

Display the logs and invisibly return the logs.


Register a function that returns a ggplot object This is usually implemented by ggplot extensions.

Description

Register a function that returns a ggplot object This is usually implemented by ggplot extensions.

Usage

register(f, name = NULL)

Arguments

f

A function that returns a ggplot object.

name

A string to represent the name of the function.

Value

A function that returns a ggplot object with logged calls.