Skip to contents

Interactively edit a masking copy of the source code

Usage

ggedit(method, remove_trace = FALSE, ...)

Arguments

method

A function or a ggproto method. The ggproto method may be specified using any of the following forms:

  • ggproto$method

  • namespace::ggproto$method

  • namespace:::ggproto$method

remove_trace

Whether to edit from a clean slate. Defaults to FALSE.

...

Unused, for extensibility.

Details

Like base::trace(), the edit is in effect until gguntrace() is called. Changes with ggedit() are cumulative, so ggedit() will inform you via a warning if you're making an edit on top of an existing edit. Call gguntrace() on the object first if you'd like to edit the method's original unaltered source code.

Only works in interactive contexts.

Gotchas

  • Calling ggtrace() on an method that that has changes from ggedit() will remove the changes from ggedit(). It is possible to combine both features, but disabled in the package to keep the API consistent. It is against the philosophy of {ggtrace} to mix programmatic and interactive workflows.

Examples

if (FALSE) { # \dontrun{

jitter_plot <- ggplot(diamonds[1:1000,], aes(cut, depth)) +
  geom_point(position = position_jitter(width = 0.2, seed = 2021))

# Interactively modify the method's source code in text editor
ggedit(PositionJitter$compute_layer)

# Check the edited code
ggbody(PositionJitter$compute_layer)

# Execute method with edit
jitter_plot

# Untrace
gguntrace(PositionJitter$compute_layer)

# Edit is removed in the next call
jitter_plot

} # }