Learn R Programming

GGenemy (version 0.1.0)

gg_suggest_fixes: Generate Code Suggestions to Fix Issues

Description

Takes an audit report and generates actionable R code to fix issues. Can also attempt to automatically fix the plot.

Usage

gg_suggest_fixes(audit_report, auto_fix = FALSE, copy_to_clipboard = FALSE)

Value

If auto_fix is TRUE, returns a fixed ggplot2 object. Otherwise returns a list of code suggestions.

Arguments

audit_report

An object returned by gg_audit(), or a ggplot2 object

auto_fix

Logical. If TRUE, attempts to automatically apply fixes. Default is FALSE.

copy_to_clipboard

Logical. If TRUE, copies suggested code to clipboard. Default is FALSE.

Examples

Run this code
library(ggplot2)
p <- ggplot(mtcars, aes(wt, mpg, color = factor(cyl))) +
  geom_point() +
  scale_color_manual(values = c("red", "green", "blue"))

# Get suggestions
gg_suggest_fixes(p)

# Auto-fix the plot
p_fixed <- gg_suggest_fixes(p, auto_fix = TRUE)

Run the code above in your browser using DataLab