Created
April 3, 2025 02:15
-
-
Save isterin/76face44fb02fdb024aa0a7ca6579e32 to your computer and use it in GitHub Desktop.
Example R Integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(arrow) | |
library(dplyr) | |
library(dataconnect) | |
dc <- dataconnect::init(api_key) | |
datasets <- dc$list(study = "12345") | |
for (ds in datasets) { | |
print(cat("Dataset: ", ds$name)) | |
} | |
dataset_frame <- dc$list(study = "12345", dataset = "DS")$frame | |
result <- dataset_frame %>% | |
filter(hr > 150) %>% | |
select(patient_id, hr, bp_sys, bp_dias) %>% | |
summarize(avg_sys = mean(bp_sys, na.rm = TRUE)) %>% | |
collect() # Pull result into a regular data frame for use in R | |
# View the result | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment