Data Access - PeekbankR
The peekbankr package loads the Peekbank tables into R as tidy data frames, reading from the versioned peekbank dataset on Redivis.
Installation
Section titled “Installation”# install.packages("remotes")
remotes::install_github("peekbank/peekbankr")Authorising Redivis
Section titled “Authorising Redivis”You need a free Redivis account. The first data request opens a browser window asking you to grant access; approve it once and later sessions reuse it.
Scripts that cannot open a browser use a personal API token instead. Create one in your Redivis workspace settings and put it in your .Renviron:
REDIVIS_API_TOKEN=your-token-hereBasic Usage
Section titled “Basic Usage”A connection pins one database version for everything that follows:
library(peekbankr)
con <- connect_to_peekbank()Pass it to the get_ functions:
datasets <- get_datasets(connection = con)
head(datasets)
pomper_admins <- get_administrations(dataset_name = "pomper_saffran_2016", connection = con)
head(pomper_admins)Leaving connection out works, but re-resolves the version on every call and warns — a long analysis can end up spanning two releases.
Pinning a Release
Section titled “Pinning a Release”connect_to_peekbank() uses the latest release by default. Pin the one you wrote your analysis against to keep it reproducible:
get_db_info() # available releases, and the Redivis version each maps to
con <- connect_to_peekbank(db_version = "2025.1")See Releases for what each release contains.
Quick Analysis Example
Section titled “Quick Analysis Example”library(dplyr)
library(ggplot2)
aoi_data <- get_aoi_timepoints(dataset_name = "pomper_saffran_2016", connection = con)
target_looks <- aoi_data %>%
group_by(t_norm) %>%
summarise(prop_target = mean(aoi == "target", na.rm = TRUE), .groups = "drop")
ggplot(target_looks, aes(x = t_norm, y = prop_target)) +
geom_line() +
labs(x = "Time (ms)", y = "Proportion target", title = "Target looking")