LLMs for Data Analysis in R
Photo by Jaroslaw Glogowski on Unsplash


Most LLMs are accessible through HTTP APIs
<Chat Anthropic/claude-sonnet-4-5 turns=2 input=15 output=37 cost=$0.00>
── user ─────────────────────────────────────────────────────────────────────────────────
Tell me a quick fact about sheep.
── assistant [input=15 output=37 cost=$0.00] ────────────────────────────────────────────
Sheep have rectangular pupils that give them a nearly 360-degree field of vision, allowing them to see predators approaching from almost any direction without turning their heads.Messages have roles.
| Role | Description |
|---|---|
system_prompt |
Instructions from the developer (i.e., you) to set the behavior of the assistant |
user |
Messages from the person interacting with the assistant |
assistant |
The AI model’s responses to the user |
<Chat Anthropic/claude-sonnet-4-5 turns=3 input=17 output=23 cost=$0.00>
── system ───────────────────────────────────────────────────────────────────────────────
Always answer in haikus.
── user ─────────────────────────────────────────────────────────────────────────────────
what is chirality
── assistant [input=17 output=23 cost=$0.00] ────────────────────────────────────────────
Molecules can twist,
Left hand, right hand—mirror forms,
Same but different.02_conversationSet up a chat with a system prompt instructing the model to answer briefly.
Ask: What ellmer function tells me what Anthropic models are available?
Ask: What about OpenAI models?
Create a new chat with no system prompt and ask the second question again.
How do the answers to 3 and 4 differ? Think about both the content and the style.
05:00
clearbot👩💻 _demos/01_clearbot/app.py
Photo by Marija Zaric on Unsplash
The LLM doesn’t remember anything between requests
You have to send the entire conversation history with every message
The LLM reconstructs the “conversation” from what you send
Photo by Andy Kelly on Unsplash
If you read everything
ever written…
Books and stories
Websites and articles
Poems and jokes
Questions and answers
…then you could…
un|con|ventionaltoken-possibilities👩💻 _demos/02_token-possibilities/app.R
It’s okay to (mostly) treat LLMs as black boxes.
Just try it! When wondering if an LLM can do something,
experiment rather than theorize
You might think they could not possibly do things
that they clearly can do today
And you might think surely they can do something
that it turns out they’re terrible at
Photo by National Cancer Institute on Unsplash
| Console | Browser | |
|---|---|---|
![]() |
live_console(chat) |
live_browser(chat) |
live👩💻 _demos/03_live/03_live.R