Code
install.packages(c("httr2", "jsonlite", "glue", "ellmer", "shiny"))R’s strength lies in both its statistical capabilities and its open-source nature. Its code is freely available to inspect, modify, and improve, supporting a global community of statisticians, data scientists, and developers.
R packages extend the language with reusable functions, data, and documentation. Community members develop packages for many academic domains (see CRAN Task Views), allowing you to build on established and emerging analytical methods.
Start by installing the packages below from CRAN in your R console. You generally install a package once per R library, then load it in each session where you need it. Later activities introduce additional packages as needed.
install.packages(c("httr2", "jsonlite", "glue", "ellmer", "shiny"))For the API connection examples, load these two packages:
library(httr2)
library(jsonlite)These commands normally complete without printing output. If R reports that a package is missing, install it in the R session you are using, then try loading it again.
The workshop’s call_claude_AIMECON26.R helper is an R script, not a package to install with install.packages(). It defines call_claude() and uses httr2 to communicate with Anthropic’s API.
Here are the main roles of these packages in the workshop:
| Package | Workshop use |
|---|---|
httr2 |
Build and send HTTP requests to an API. |
jsonlite |
Convert between R objects and JSON data. |
glue |
Insert values into reusable prompt templates. |
ellmer |
Manage conversations with LLMs from R. |
shiny |
Build interactive web applications with R. |
The workshop helper uses httr2, while jsonlite is used in later examples for working directly with JSON data.
We’ll explore prompt templates and JSON in Practical Tools, and web applications in R Shiny.
Several R packages provide interfaces to large language models (LLMs). We’ll use ellmer for conversational interactions. For other options, see the LLM-specific R packages in the reference materials.