Skip to content

Commit

Permalink
R/Medicine 2024 part 1a
Browse files Browse the repository at this point in the history
  • Loading branch information
wibeasley committed Jun 11, 2024
1 parent 6f1afaf commit 623a445
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 3 deletions.
101 changes: 101 additions & 0 deletions documentation-for-developers/r-meidicine-2024-part-1.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
## ----pre-req------------------------------------------------------------------
requireNamespace("REDCapR")

# If this fails, run `install.packages("REDCapR")` or `remotes::install_github(repo="OuhscBbmc/REDCapR")`

## ----retrieve-credential------------------------------------------------------
path_credential <- system.file("misc/example.credentials", package = "REDCapR")
credential <- REDCapR::retrieve_credential_local(
path_credential = path_credential,
project_id = 3181
)

credential

## ----unstructured-1-----------------------------------------------------------
ds_1 <-
REDCapR::redcap_read(
redcap_uri = credential$redcap_uri,
token = credential$token
)$data

View(ds_1)


# View corresponding REDCap project in browser:
# https://bbmc.ouhsc.edu/redcap/redcap_v14.3.13/DataEntry/record_home.php?pid=3181&arm=1&id=1


# ---- redcap_metadata_read ----------------------------------------------------
REDCapR::redcap_metadata_read(
redcap_uri = credential$redcap_uri,
token = credential$token
)$data


# ---- grain - intake -----------------------------------------------------------
col_types_intake <-
readr::cols_only(
record_id = readr::col_integer(),
height = readr::col_double(),
weight = readr::col_double(),
bmi = readr::col_double()
)

ds_intake <-
REDCapR::redcap_read(
redcap_uri = credential$redcap_uri, # From the previous code snippet.
token = credential$token,
forms = "intake",
col_types = col_types_intake,
verbose = FALSE,
)$data

ds_intake


# ---- grain - bp --------------------------------------------------------------
col_types_blood_pressure <-
readr::cols(
record_id = readr::col_integer(),
redcap_repeat_instrument = readr::col_character(),
redcap_repeat_instance = readr::col_integer(),
sbp = readr::col_double(),
dbp = readr::col_double(),
blood_pressure_complete = readr::col_integer()
)

ds_blood_pressure <-
REDCapR::redcap_read(
redcap_uri = credential$redcap_uri,
token = credential$token,
forms = "blood_pressure",
col_types = col_types_blood_pressure,
verbose = FALSE
)$data

ds_blood_pressure |>
tidyr::drop_na(redcap_repeat_instrument)

# ---- grain - labs ------------------------------------------------------------
col_types_laboratory <-
readr::cols(
record_id = readr::col_integer(),
redcap_repeat_instrument = readr::col_character(),
redcap_repeat_instance = readr::col_integer(),
lab = readr::col_character(),
conc = readr::col_character(),
laboratory_complete = readr::col_integer()
)

ds_laboratory <-
REDCapR::redcap_read(
redcap_uri = credential$redcap_uri,
token = credential$token,
forms = "laboratory",
col_types = col_types_laboratory,
verbose = FALSE
)$data

ds_laboratory |>
tidyr::drop_na(redcap_repeat_instrument)
8 changes: 5 additions & 3 deletions vignettes/workflow-write.Rmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Writing to a REDCap Project"
author: Will Beasley [Biomedical & Behavior Methodology Core](https://www.ouhsc.edu/bbmc/team/), OUHSC Pediatrics;<br>Raymond Balise, University of Miami School of Medicine
author: Will Beasley [Biomedical & Behavior Methodology Core](https://www.ouhsc.edu/bbmc/team/), OUHSC Pediatrics;;<br>Raymond Balise, University of Miami School of Medicine<br>Stephan Kadauke, Children's Hospital of Philadelphia
output:
rmarkdown::html_vignette
vignette: >
Expand Down Expand Up @@ -357,8 +357,10 @@ Notes
This vignette was originally designed for the
[2023 R/Medicine](https://events.linuxfoundation.org/r-medicine/) workshop,
_Using REDCap and R to Rapidly Produce Biomedical Publications Cleaning Medical Data_
with [Raymond R. Balise](https://github.com/RaymondBalise), Belén Hervera, Daniel Maya, Anna Calderon, Tyler Bartholomew, Stephan Kadauke, and João Pedro Carmezim Correia.
The entire workshop's slides are at <https://github.com/RaymondBalise/r_med_redcap_2023_public>.
with [Raymond R. Balise](https://github.com/RaymondBalise), Belén Hervera, Daniel Maya, Anna Calderon, Tyler Bartholomew, Stephan Kadauke, and João Pedro Carmezim Correia and the [2024 R/Medicine](https://rconsortium.github.io/RMedicine_website/Program.html) workshop,
_REDCap + R: Teaming Up in the Tidyverse_, with Stephan Kadauke.
The workshop slides are for [2023](https://github.com/RaymondBalise/r_med_redcap_2023_public)
and [2024](https://github.com/skadauke/rmedicine_2024_redcap_r_workshop).

This work was made possible in part by the NIH grant [U54GM104938](https://taggs.hhs.gov/Detail/AwardDetail?arg_AwardNum=U54GM104938&arg_ProgOfficeCode=127)
to the [Oklahoma Shared Clinical and Translational Resource)](http://osctr.ouhsc.edu).
Expand Down

0 comments on commit 623a445

Please sign in to comment.