Learn R Programming

NBDCtools

This R package provides functions for working with data released by the NIH Brain Development Cohorts (NBDC) Data Hub, which currently offers data for the ABCD and HBCD studies.

The NBDCtools package is designed to help researchers and data analysts create analysis-ready datasets from the tabulated data released by the ABCD and HBCD studies. Its core functionality is to join selected variables and/or entire tables from the tabulated data files into a single data frame in memory. Additionally, the package offers several functions to assist users in working with the data, including:

  • Transformation functions to convert categorical columns to (ordered or unordered) factors based on the data dictionary and levels table, or to add variable and value labels to a dataset.
  • Filter/subsetting functions to filter by a set of participant/events, filter ABCD events using shorthands, or exclude rows or columns with only missing data.
  • Functions to retrieve and utilize metadata from the studies.
  • A set of utility functions for various use cases.

Installation

IMPORTANT: Besides the NBDCtools main package, users also need to install the accompanying NBDCtoolsData package, which contains the large data dictionary and levels tables used by the NBDCtools package.

To install the stable version of the main package from CRAN, and the data package from r-universe, use the following command:

install.packages("NBDCtools")
install.packages("NBDCtoolsData", repos = "https://nbdc-datahub.r-universe.dev")

To install the latest version of the packages from GitHub, use the following command:

if (!requireNamespace("remotes", quietly = TRUE)) {
  install.packages("remotes")
}
  
remotes::install_github("nbdc-datahub/NBDCtools")
remotes::install_github("nbdc-datahub/NBDCtoolsData")

There are some additional dependencies that are not installed by default, as they are only needed for specific features, such as processing shadow matrices. To install all the dependencies, use the following command:

install.packages("NBDCtools", dependencies = TRUE)
# or some specific dependencies
install.packages("naniar") # e.g. shadow matrix processing

To install a specific version of the package, specify the version number in the remotes::install_github() call. For example, to install version 1.0.0, use the following command:

remotes::install_github("nbdc-datahub/NBDCtools@v1.0.0")
remotes::install_github("nbdc-datahub/NBDCtoolsData@v1.0.0")

NOTE: The NBDCtoolsData package version does not match the NBDCtools package version, i.e., the two package follow different release cycles. For example, the NBDCtools package may not be changed across ABCD/HBCD data releases, but the NBDCtoolsData package is updated with each data release. Therefore, it is recommended to always update the data package to the latest version.

Usage

For a general overview of how to download data from the NBDC Data Hub and use this R package to create custom datasets, see the Get Started page. To browse the documentation of all available functions, see the Reference page. For more detailed information about different categories of functions, refer to the vignettes.

Issues

If you encounter issues while using this package, please report them by submitting a GitHub issue. Please do not submit any issues related to the ABCD or HBCD data resources themselves (see here for information on how to report issues with the data resource).

Citation

We are currently preparing a paper about NBDCtools. The reference will be added here once the paper is published.

Copy Link

Version

Install

install.packages('NBDCtools')

Monthly Downloads

260

Version

1.0.2

License

GPL (>= 3)

Maintainer

Le Zhang

Last Published

October 5th, 2025

Functions in NBDCtools (1.0.2)

read_file

Read file
shadow_bind_data

Bind the shadow matrix to the data
get_sessions

Get sessions table
shadow_replace_binding_missing

Fix binding resulted missingness in shadow matrices
join_by_identifier

Join by identifier set
transf_value_to_label

Convert values to labels for categorical variables
transf_value_to_na

Convert categorical missingness/non-response codes to NA
get_id_cols

Get identifier columns
get_dd

Get data dictionary
transf_time_to_hms

Convert time columns to hms format
transf_label

Add variable/value labels
transf_factor

Convert categorical columns to factor
convert_names_file

Convert column names in a file
filter_empty_cols

Filter empty columns
NBDCtools-package

NBDCtools: National Institutes of Health Brain Development Cohorts Data Hub Tools
convert_names_data

Convert column names in a data frame
filter_id_events

Filter ID/events
filter_empty_rows

Filter empty rows
create_bids_sidecar

Create BIDS sidecar
create_dataset

Create a dataset
filter_events_abcd

Filter ABCD events
read_dsv_formatted

Read delimiter (tab/comma) separated values file correctly formatted
join_tabulated

Join tabulated data
get_levels

Get levels table
get_metadata

Get metadata
benchmark_models

Benchmark Models