querychat

LLMs for Data Analysis in R

R/Medicine 2026

What is querychat?

  • Explore data using natural language

  • Built on top of ellmer and Shiny

  • Works with data frames and database connections

Demo

👩‍💻 _demos/05_querychat/05_querychat-dashboard.R

How does querychat work?

  1. You ask a question in natural language

  2. The LLM writes a SQL query

  3. A database executes the query

  4. You get back real, filtered data

Benefits

  • Reliable — the database runs the queries, not the LLM. No hallucinated numbers.

  • Safe — limited to read-only queries. No data destruction.

  • Reproducible — SQL can be exported and re-run.

The simplest version

library(querychat)

querychat_app(your_data)

Your Turn 07_querychat

  1. Open 07_querychat-app.R and fill in the querychat_app() call.

  2. Run it and explore the health expenditure dataset with natural language.

  3. Try questions like:

    • “Which country spent the most on preventive care in 2020?”
    • “Show me spending by purpose for Japan”
04:00

shinychat