Review an R script with an LLM
review.RdLaunches an interactive Shiny app where an LLM reviews your R code and suggests improvements for reproducibility, readability, and resilience. The app displays your code with proposed edits highlighted inline. You can accept or reject each suggestion, and accepted edits are applied to the file immediately.
Arguments
- file_path
Path to the R file to review.
- client
The model to use for the review, either as an ellmer::Chat object or a
"provider/model"string in the same format accepted byellmer::chat(). If not provided, thereviewer.clientoption will be consulted. See reviewer_options for details. If neither are present, the user will be shown an interactive dialog to select a client.- max_pending
Maximum number of pending edits allowed at once before the model waits for user responses. Higher values reduce wait time but may feel more overwhelming. If not provided, the
reviewer.pending_editsoption is used. Defaults to 2.
Value
The function's main purpose is its side-effect, a Docs-style
interface opened in the browser. On app close, the ellmer::Chat object
used for the review session is returned invisibly. The underlying chat object
is stored as .last_review on the search path for easy access after review.
Examples
if (FALSE) { # \dontrun{
# Set the client option (possibly in your .Rprofile)
options(reviewer.client = ellmer::chat_openai(model = "gpt-5.2"))
review("analysis.R")
# Or pass the client directly
review("script.R", client = "openai/gpt-5.2")
review("script.R", client = ellmer::chat_openai(model = "gpt-5.2"))
} # }