In the world of R programming, generative AI tools are transforming the way developers write, troubleshoot, and optimize code. In my previous article, I explored some of the best tools for integrating large language models (LLMs) into R scripts and workflows. Now, I’ll expand on that by introducing a collection of powerful generative AI tools designed specifically to enhance your R programming experience—whether by offering code assistance or enabling you to run LLMs locally within your R environment.
One of the most common uses for large language models is to help developers write and optimize their code. This is especially true for R developers who need quick assistance with syntax, debugging, or improving their code. Many developers prefer to integrate LLMs directly into their integrated development environments (IDEs), while others may opt to use external tools and copy-paste their code for suggestions. Regardless of your approach, there are several generative AI tools available for R programmers, both for direct code assistance and for running LLMs locally within your setup.
One such tool is gander, an IDE add-in for RStudio and Positron that acts like a lightweight version of GitHub Copilot specifically for R scripts. gander integrates directly into your IDE, making it aware of the code within your current script as well as the variables in your environment. When you invoke gander, you have the option to select code and either replace it or add the model’s suggestions before or after your selected code. This flexibility allows you to fine-tune the results, providing a more seamless experience while writing R code.
gander supports various models via the ellmer package, with one notable recommendation being Anthropic’s Claude Sonnet, which is praised for its R programming capabilities. Setting up gander is straightforward—you simply need to configure your API key for a commercial LLM provider, or you can run models locally using ollama. This flexibility allows developers to choose between cloud-based or local solutions depending on their needs. Additionally, ellmer, which powers gander, can also function as a chatbot to answer specific R-related questions, making it an excellent all-in-one tool for developers seeking code assistance or local LLM execution.