
gander is a higher-performance and lower-friction chat experience fordata scientists in RStudio and Positron–sort of like completions withCopilot, but it knows how to talk to the objects in your R environment.The package bringsellmerchats into your project sessions, automatically incorporating relevantcontext and streaming their responses directly into your documents.
Why not just chat? In many ways, working with ganderis just like using a chat interface online or viashinychat. The ganderassistant will automatically find the context it needs, though:
Important
For now, gander is particularly effective in
.Rfilesbut struggles to provide appropriately formatted responses in.Qmdand related file formats.
You can install gander like so:
install.packages("gander")To install the developmental version:
pak::pak("simonpcouch/gander")Then, you’ll need to hook gander up with anellmer chat. gander uses the.gander_chat option to configure which model powers theaddin; just set the option to whatever your usual ellmer setup is. Forexample, we recommend Anthropic’s Claude Sonnet 3.5, which you can useviaoptions(.gander_chat = ellmer::chat_claude()) onceyou’ve configured anANTHROPIC_API_KEY. Paste that code inyour.Rprofile viausethis::edit_r_profile()to always use the same model every time you start an R session. gandersupports any model supported by ellmer, so you can use Anthropic’sClaude, OpenAI’s GPT-4o, local ollama models, etc. See “Choosing amodel” invignette("gander", package = "gander") to learnmore.
The gander assistant is interfaced with the via the gander addin. Foreasiest access, we recommend registering the gander addin to a keyboardshortcut.
In RStudio, navigate toTools > Modify Keyboard Shortcuts > Search "gander"—wesuggestCtrl+Alt+G (orCtrl+Cmd+G onmacOS).
In Positron, you’ll need to open the commandpalette, run “Open Keyboard Shortcuts (JSON)”, and paste the followinginto yourkeybindings.json:
{"key":"Ctrl+Cmd+G","command":"workbench.action.executeCode.console","when":"editorTextFocus","args":{"langId":"r","code":"gander::gander_addin()","focus":true}}The analogous keybinding on non-macOS isCtrl+Alt+G.That said, change the"key" entry to any keybinding youwish!
Once those steps are completed, you’re ready to use the ganderassistant with a keyboard shortcut.
This screencast demonstrates using the gander addin to iterate on aplot:
After loading the stackoverflow data into my environment, I highlightstackoverflow and type a plain language request to plot thedata. The LLM’s response—which provides a minimal solution and refers tocorrect column names—is streamed directly into my document and selectedin whole. After visually inspecting, I run the code, and then retriggerthe addin and type a followup request to refine the plot, doing soiteratively until I’m satisfied with my results.
To read more about using the addin, check out the Getting Startedvignette withvignette("gander", package = "gander").