The year/Independent research

Paper 2603.04743

DARE: Aligning LLM Agents with the R Statistical Ecosystem via Distribution-Aware Retrieval

Published
Mar 2026
Research lab
Independent
Citations
3
GitHub
15 stars

01 In brief

Summary

The paper introduces DARE (Distribution-Aware Retrieval Embedding), a lightweight retrieval model that incorporates data distribution information into function representations for retrieving R packages, addressing the underuse of rigorous statistical methods in R by LLM agents.

The authors construct RPKB, a curated knowledge base from 8,191 CRAN packages, and propose DARE, a bi-encoder model that fuses distributional features with function metadata.

DARE achieves an NDCG@10 of 93.47%, outperforming state-of-the-art open-source embedding models by up to 17% while using only 23M parameters.

They also design RCodingAgent, an R-oriented LLM agent, and evaluate it on 16 statistical analysis tasks.

Integrating DARE into RCodingAgent improves success rates by up to 56.25% across various LLMs, including frontier models.

The work aims to bridge the gap between LLM automation and the R statistical ecosystem.

02 From the paper

Abstract

Large Language Model (LLM) agents can automate data-science workflows, but many rigorous statistical methods implemented in R remain underused because LLMs struggle with statistical knowledge and tool retrieval. Existing retrieval-augmented approaches focus on function-level semantics and ignore data distribution, producing suboptimal matches. We propose DARE (Distribution-Aware Retrieval Embedding), a lightweight, plug-and-play retrieval model that incorporates data distribution information into function representations for R package retrieval. Our main contributions are: (i) RPKB, a curated R Package Knowledge Base derived from 8,191 high-quality CRAN packages; (ii) DARE, an embedding model that fuses distributional features with function metadata to improve retrieval relevance; and (iii) RCodingAgent, an R-oriented LLM agent for reliable R code generation and a suite of statistical analysis tasks for systematically evaluating LLM agents in realistic analytical scenarios. Empirically, DARE achieves an NDCG at 10 of 93.47%, outperforming state-of-the-art open-source embedding models by up to 17% on package retrieval while using substantially fewer parameters. Integrating DARE into RCodingAgent yields significant gains on downstream analysis tasks. This work helps narrow the gap between LLM automation and the mature R statistical ecosystem.