Interactively edit a masking copy of the source code
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 fromggedit()
will remove the changes fromggedit()
. 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
} # }