Package: redquack 0.1.1

Dylan Pieper

redquack: Transfer 'REDCap' Data to 'DuckDB'

Provides a single function to transfer 'REDCap' (Research Electronic Data Capture) data to a 'DuckDB' database. Processes data in chunks to handle large datasets while minimizing memory usage. Features include resuming incomplete transfers, converting column types, tracking progress, logging operations in the database.

Authors:Dylan Pieper [aut, cre]

redquack_0.1.1.tar.gz
redquack_0.1.1.tar.gz(r-4.5-noble)redquack_0.1.1.tar.gz(r-4.4-noble)
redquack_0.1.1.tgz(r-4.4-emscripten)redquack_0.1.1.tgz(r-4.3-emscripten)
redquack.pdf |redquack.html
redquack/json (API)
NEWS

# Install 'redquack' in R:
install.packages('redquack', repos = 'https://cloud.r-project.org')

On CRAN:

Conda:

This package does not link to any Github/Gitlab/R-forge repository. No issue tracker or development information is available.

1.70 score 1 exports 37 dependencies

Last updated 21 hours agofrom:d3e11f390d. Checks:3 OK. Indexed: no.

TargetResultLatest binary
Doc / VignettesOKMar 24 2025
R-4.5-linuxOKMar 24 2025
R-4.4-linuxOKMar 24 2025

Exports:redcap_to_duckdb

Dependencies:askpassaudiobeeprbitbit64clicliprcpp11crayoncurlDBIdplyrduckdbfansigenericsgluehmshttr2lifecyclemagrittropensslpillarpkgconfigprettyunitsprogressR6rappdirsreadrrlangsystibbletidyselecttzdbutf8vctrsvroomwithr

Citation

To cite package ‘redquack’ in publications use:

Pieper D (2025). redquack: Transfer 'REDCap' Data to 'DuckDB'. R package version 0.1.1, https://CRAN.R-project.org/package=redquack.

Corresponding BibTeX entry:

  @Manual{,
    title = {redquack: Transfer 'REDCap' Data to 'DuckDB'},
    author = {Dylan Pieper},
    year = {2025},
    note = {R package version 0.1.1},
    url = {https://CRAN.R-project.org/package=redquack},
  }

Readme and manuals

redquack

Transfer REDCap data to DuckDB with minimal memory overhead, designed for large datasets that exceed available RAM.

Features

  • Chunked transfers for memory efficiency
  • Auto-resume from interruptions
  • Optimal data type conversion
  • Timestamped operation logs
  • Configurable API request retries
  • Real-time progress indicators
  • Completion notifications (🔊 🦆)

Installation

From CRAN:

install.packages("redquack")

Development version:

# install.packages("pak")
pak::pak("dylanpieper/redquack")

Basic Usage

Data from REDCap is transferred to DuckDB in configurable chunks of record IDs:

library(redquack)

con <- redcap_to_duckdb(
  redcap_uri = "https://redcap.example.org/api/",
  token = "YOUR_API_TOKEN",
  record_id_name = "record_id",
  chunk_size = 1000  
  # Increase chunk size for memory-efficient systems (faster)
  # Decrease chunk size for memory-constrained systems (slower)
)
Working with the data

Query the data with dplyr:

library(dplyr)

demographics <- tbl(con, "data") |>
  filter(demographics_complete == 2) |>
  select(record_id, age, race, gender) |>
  collect()

age_summary <- tbl(con, "data") |>
  group_by(gender) |>
  summarize(
    n = n(),
    mean_age = mean(age, na.rm = TRUE),
    median_age = median(age, na.rm = TRUE)
  ) |>
  collect()

Create a Parquet file directly from DuckDB (efficient for sharing data):

DBI::dbExecute(con, "COPY (SELECT * FROM data) TO 'redcap.parquet' (FORMAT PARQUET)")

Remember to close the connection when finished:

DBI::dbDisconnect(con, shutdown = TRUE)

Database structure

The DuckDB database created by redcap_to_duckdb() contains two tables:

  1. data: Contains all exported REDCap records with optimized column types

    DBI::dbGetQuery(con, "SELECT * FROM data LIMIT 10")
    
  2. log: Contains timestamped logs of the transfer process for troubleshooting

    DBI::dbGetQuery(con, "SELECT timestamp, type, message FROM log ORDER BY timestamp")
    

Help Manual

Help pageTopics
Transfer 'REDCap' Data to 'DuckDB'redcap_to_duckdb