Skip to content
cd /languages
  • Statistical computing
  • Programming
  • AST and symbol support

R Support in Maguyva: Code Graphs for Analysis and Package Code

Maguyva parses R with AST, symbol, and graph support, so AI agents can follow functions, S3 and S4 dispatch, and model-fitting calls across R scripts and packages.

Where R trips up shallow AI tools

R puts base functions, package functions, and your own in one flat namespace. Dots are part of names, not member access: is.na, data.frame, and print.summary_table are single identifiers. A tool that reads print.summary_table as a method on print gets the structure wrong, and one that records every base call buries your functions under c() and paste().

Maguyva keeps R names whole and filters the base noise, so an agent sees the functions your analysis actually depends on.

What Maguyva extracts in R

Maguyva maps .R, .Rmd, and .Rnw files to R. Functions assigned to a name, such as clean_survey <- function(df), are extracted under that name, and anonymous functions are not treated as definitions. Dotted names are never split into a receiver and a member.

Some base R calls stay in the graph on purpose because they show how analysis code is wired: S3 and S4 dispatch (UseMethod, standardGeneric), the apply family (lapply, sapply, vapply, mapply), model fitting (lm, predict, anova), package loading (library, require), and error handling with tryCatch.

The graph also records instantiation and reads and writes.

Example agent prompts

  • “Who calls clean_survey, and which models use its output?” (find_symbol, then dependency_search incoming)
  • “Which functions call fit_model?” (dependency_search)
  • “Trace the path from load_raw_data to the final regression.” (get_task_context)

Known limits

  • About 800 base R, stats, and graphics names are filtered from relationships, such as print, paste, c, data.frame, plotting calls, and random-number generators. Use text_pattern_search for them.
  • R creates classes and loads packages with ordinary function calls, so the classes, imports, and variables presets in structural_search select nothing. Use find_symbol and text_pattern_search.
  • .Rmd and .Rnw files are read with the R grammar as a whole rather than chunk by chunk, so expect partial results for R Markdown and Sweave documents.
  • R has no decorator syntax, so decorator relationships are marked not applicable.

Next steps

Connect a repository with the quickstart, then check the support matrix on the compatibility page. For mixed data-science repos, read the Python guide too.

Best fit

  • > R packages with many exported functions, S3 methods, and internal helpers.
  • > Analysis pipelines split across scripts that share data-cleaning and modelling functions.
  • > Data teams handing R code to AI agents that need to see which functions feed which models.

Agent workflows

  • > Find every caller of a data-cleaning function before changing the columns it returns.
  • > Trace which functions dispatch through `UseMethod` and where their methods live.
  • > Map the path from raw data loading to a fitted model.

Engine details

  • > R support maps `.R`, `.Rmd`, and `.Rnw`. Functions assigned to a name are extracted under that name, and dotted names such as `data.frame` stay whole.
  • > S3 and S4 dispatch (`UseMethod`, `standardGeneric`), the apply family, `lm`, `predict`, and `tryCatch` are kept in the graph on purpose.
  • > About 800 base R, `stats`, and `graphics` names, such as `print`, `paste`, and `c`, are filtered from relationships.

Useful MCP entry points

  • find_symbol

    Use it for a cleaning, modelling, or S3 method name when you need the definition and callers.

  • dependency_search

    Use incoming traversal on a helper function to see which analyses depend on it before changing its output.

  • get_task_context

    Use it for prompts like “trace the path from raw data loading to the final regression.”