Skip to contents

What This Agent Does

build_data_wrangling_agent() helps with joins, reshaping, transformations, and repeatable wrangling functions.

Workflow Diagram

Generate Mermaid PNGs

library(LLMAgentR)

my_llm_wrapper <- function(prompt, verbose = FALSE) "LLM response placeholder"

workflow <- build_data_wrangling_agent(
  model = my_llm_wrapper,
  output = "both",
  direction = "LR"
)

save_mermaid_png(
  x = workflow,
  file = "pkgdown/assets/data-wrangling-agent-workflow.png"
)

Step 1: Build the Agent

library(LLMAgentR)

my_llm_wrapper <- function(prompt, verbose = FALSE) "LLM response placeholder"

wrangler <- build_data_wrangling_agent(
  model = my_llm_wrapper,
  human_validation = FALSE,
  bypass_recommended_steps = FALSE,
  bypass_explain_code = FALSE,
  verbose = FALSE
)

Step 2: Run with a State List

initial_state <- list(
  data_raw = mtcars,
  user_instructions = "Group by cyl and return average mpg and hp.",
  max_retries = 3,
  retry_count = 0
)

final_state <- wrangler(initial_state)
str(final_state)

Notes for Beginners

  • This agent is for structure changes, not only cleaning.
  • Use clear instructions: group, filter, join, pivot, summarize.
  • Review generated function code before production use.