Accessing and Using Data in webR

Possible avenues for Data Retrieval


James Joseph Balamuta


January 14, 2024


April 10, 2024


When working with data in webR, there are some tricks to using data in the web environment. This documentation entry guides you through a few changes related to accessing data.

Accessing Data through R Data Packages

One approach to accessing data is to store the data inside of an R data package. This kind of R package consists solely of data in an R ready format with the added benefit of help documentation. If the data package is on CRAN, chances are there is a version available for webR on the main repository (warning not a mobile data friendly link) and, thus, can be accessed using install.packages("pkg") or added to the documents packages key. Otherwise, the R package will need to be converted, deployed, and accessed through GitHub Pages by following the advice to setup a custom package repository.

Retrieving Data from the Web


Before proceeding, take note of the following considerations when working with remote data:

  1. Security Protocol: webR necessitates data retrieval via the HyperText Transfer Protocol Secure (HTTPS) protocol to ensure secure connections and the Cross-Origin Resource Sharing (CORS) being enabled.
  2. Package Compatibility: In the absence of websockets within webR, packages reliant on {curl} methods may require adaptation or alternative solutions.

When retrieving data in webR, it is imperative to always use links that use HyperText Transfer Protocol Secure (HTTPS). From there, the data at the HTTPS URL can be downloaded using the download.file() function and subsequently reading it into R utilizing a relative path. Follow this example:

url <- ""
download.file(url, "data.csv")

This action saves the file into webR’s virtual file system to be read into R’s analysis environment. Replace "" with the actual URL of your desired data source.

Base R

For optimized performance, leverage base R’s read.*() functions, as they do not necessitate additional package dependencies.

data <- read.csv("data.csv")


Alternatively, you can use tidyverse-based functions like readr::read_*().


Note that employing tidyverse or readr functions entails additional package downloads at the session’s outset or immediately preceeding the function usage.

data <- readr::read_csv("data.csv")