Package: rcprd 0.0.2

rcprd: Extraction and Management of Clinical Practice Research Datalink Data

Simplify the process of extracting and processing Clinical Practice Research Datalink (CPRD) data in order to build datasets ready for statistical analysis. This process is difficult in 'R', as the raw data is very large and cannot be read into the R workspace. 'rcprd' utilises 'RSQLite' to create 'SQLite' databases which are stored on the hard disk. These are then queried to extract the required information for a cohort of interest, and create datasets ready for statistical analysis. The processes follow closely that from the 'rEHR' package, see Springate et al., (2017) <doi:10.1371/journal.pone.0171784>.

Authors:Alexander Pate [aut, cre, cph]

rcprd_0.0.2.tar.gz
rcprd_0.0.2.zip(r-4.7-any)rcprd_0.0.2.zip(r-4.6-any)rcprd_0.0.2.zip(r-4.5-any)
rcprd_0.0.2.tgz(r-4.6-any)rcprd_0.0.2.tgz(r-4.5-any)
rcprd_0.0.2.tar.gz(r-4.7-any)rcprd_0.0.2.tar.gz(r-4.6-any)
rcprd_0.0.2.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
rcprd/json (API)

# Install 'rcprd' in R:
install.packages('rcprd', repos = c('https://alexpate30.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/alexpate30/rcprd/issues

Pkgdown/docs site:https://alexpate30.github.io

On CRAN:

Conda:

5.48 score 4 stars 15 scripts 334 downloads 19 exports 30 dependencies

Last updated from:0817decda2. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK148
source / vignettesOK256
linux-release-x86_64OK143
macos-release-arm64OK132
macos-oldrel-arm64OK163
windows-develOK86
windows-releaseOK82
windows-oldrelOK75
wasm-releaseOK129

Exports:add_to_databasecombine_querycombine_query_booleanconnect_databasecprd_extractcreate_directory_systemdb_querydelete_directory_systemextract_bmiextract_cholhdl_ratioextract_cohortextract_diabetesextract_hoextract_practicesextract_smokingextract_test_dataextract_test_data_varextract_test_recentextract_time_until

Dependencies:bitbit64blobcachemclicpp11data.tableDBIdplyrfastmapfastmatchgenericsgluelifecyclelubridatemagrittrmemoisepillarpkgconfigR6rlangRSQLitestringistringrtibbletidyselecttimechangeutf8vctrswithr

rcprd: An R package to simplify the extraction and processing of CPRD data, and create analysis-ready datasets
Introduction | Data Structure and Extraction Process | Structure of CPRD Aurum data | Recommended process for extraction | Worked example for data extraction | Steps 1 - 4: Defining a cohort | Step 5: Reading in data and creating an SQLite database | Add individual files to SQLite database using add_to_database | Add all relevant files to SQLite database using cprd_extract | Add all relevant files to SQLite database in a computationally efficient manner using the set functionality. | Step 6: Querying the SQLite database to extract variables | Functions for extracting common variable types | Functions for extracting specific variables | Functions for database queries and custom variable extraction | Saving extracted variables directly to a disk drive, and utilising rAURUMs suggested directory system | Extracting longitudinal data/time varying covariates | Working with linked data | Discussion | References

Last update: 2025-09-07
Started: 2024-10-30

Details-on-algorithms-for-extracting-specific-variables
Introduction | Algorithms for variable extraction | BMI (extract_BMI) | Cholesterol/HDL ratio (extract_cholhdl_ratio) | Diabetes status (extract_diabetes) | Smoking status (extract_smoking) | Summary of units of measurement for test data

Last update: 2025-03-26
Started: 2024-07-15

Readme and manuals

Help Manual

Help pageTopics
Adds a single .txt file to an SQLite database on the hard disk.add_to_database
Combine a database query with a cohort.combine_query
Combine a database query with a cohort returning a 0/1 vector depending on whether each individual has a recorded code of interest.combine_query_boolean
Combine a CPRD aurum database query with a cohort returning a 0/1 vector depending on whether each individual has a recorded code of interest.combine_query_boolean.aurum
Combine a CPRD aurum database query with a cohort.combine_query.aurum
Open connection to SQLite databaseconnect_database
Adds all the .txt files in a directory, with certain file names, to an SQLite database on the hard disk.cprd_extract
Create the appropriate directory system to be able to run functions without specifying hard filepathscreate_directory_system
Query an RSQLite database.db_query
Deletes directory system created by 'delete_directory_system'delete_directory_system
Extract most recent BMI score relative to an index date.extract_bmi
Extract most recent total cholesterol/high-density lipoprotein ratio score relative to an index date.extract_cholhdl_ratio
Create cohort from patient filesextract_cohort
Extract diabetes status prior to an index date.extract_diabetes
Extract a 'history of' type variableextract_ho
Combine practice filesextract_practices
Extract smoking status prior to index date.extract_smoking
Extract test data.extract_test_data
Extract standard deviation of all test data values over a specified time period relative to an index date.extract_test_data_var
Extract test data.extract_test_recent
Extract a 'time until' type variableextract_time_until
Read in txt file with all colClasses = "character"extract_txt_char
Read in raw .txt consultation fileextract_txt_cons
Read in raw ONS death data fileextract_txt_death
Read in raw .txt drugissue fileextract_txt_drug
Read in raw HES primary diagnoses fileextract_txt_hes_primary
Read in linkage eligibility fileextract_txt_linkage
Read in raw .txt observation fileextract_txt_obs
Read in raw .txt patient fileextract_txt_pat
Read in raw .txt practice fileextract_txt_prac
Read in raw .txt problem fileextract_txt_prob
Read in raw .txt referral fileextract_txt_ref
Internal function to implement saving extracted variable to disk or returning into R workspace.implement_output