Launches an interactive data exploration session using the
Write/Execute/Analyze/Regroup (WEAR) loop pattern. This is a dedicated
exploration mode – it is separate from a normal codeagent_app() or
codeagent_console() session. The difference:
Usage
wear_explore(data = NULL, client = NULL, mode = c("repl", "shiny"), ...)Arguments
- data
Named list, environment, or
NULL. Data.frames to make available for exploration. IfNULL, uses objects in.GlobalEnv. A named list is converted to an environment automatically.- client
A
CodeagentClient(fromcodeagent_client()). IfNULL, one is built from~/.codeagent/settings.jsonwithpermission_mode = "bypass".- mode
Character.
"repl"(default) starts an interactive CLI session;"shiny"launches the Shiny app.- ...
Passed to
codeagent_console()orcodeagent_app().
Value
Invisibly the CodeagentClient (useful for post-session inspection
or calling generate_wear_report() manually).
Details
| Normal session | WEAR session (wear_explore()) |
| No data registered by default | data= argument registers named data.frames |
No GenerateReport tool | /report exports session to .qmd |
| No WEAR system prompt | Agent instructed to end each turn with Next steps |
| General-purpose tools | ExploreData tool added (read-only, sandboxed) |
The ExploreData and GenerateReport tools are not registered in the
standard agent loop (codeagent_app()) – use wear_explore() to enter
exploration mode explicitly.
See also
generate_wear_report() to export the session to a Quarto document.
Examples
if (FALSE) { # \dontrun{
# Explore mtcars from the CLI (requires a configured LLM client)
wear_explore(data = list(mtcars = mtcars))
# Shiny UI with multiple data.frames
wear_explore(
data = list(sales = sales_df, products = products_df),
mode = "shiny"
)
# Capture the client to export the report afterwards
client <- wear_explore(data = list(mtcars = mtcars))
generate_wear_report(client, title = "Motor Trend Analysis")
} # }