The peekbankr package allows you to access data in peekbank from R. This removes the need to write complex SQL queries in order to get the information you want from the database. The package vignette provides some examples of how to use the data loading functions and what the resulting data look like.
peekbankr from GitHub:
install.packages("RMariaDB")
# install.packages("remotes")
remotes::install_github("peekbank/peekbankr")
When developing, you can run:
# install.packages("RMariaDB")
install.packages(".", repos = NULL, type="source", dependencies=TRUE)
After making changes, be sure to run
roxygen2::roxygenise()
to update exports and documentation.
Here’s a simple workflow for using peekbankr to get data from a single study.
library(tidyverse)
library(peekbankr)
con <- connect_to_peekbank()
aoi_timepoints <- get_aoi_timepoints(connection = con, dataset_name = "pomper_saffran_2016")
administrations <- get_administrations(connection = con, dataset_name = "pomper_saffran_2016")
ps_data <- aoi_timepoints %>%
left_join(administrations)
connect_to_peekbank() handles TLS automatically via the ssl argument (default "auto"):
127.0.0.1 or localhost skip TLS enforcement, so a local peekbank docker stack running without TLS works out of the box.To override:
# Custom self-hosted server with its own self-signed cert:
connect_to_peekbank(host = "db.example.org", ssl = "/path/to/my-ca.pem")
# Force plaintext (e.g. an unusual non-localhost development setup):
connect_to_peekbank(host = "192.168.1.42", ssl = "disabled")