Skip to content

Instantly share code, notes, and snippets.

@isterin
Created April 3, 2025 02:15
Show Gist options
  • Save isterin/76face44fb02fdb024aa0a7ca6579e32 to your computer and use it in GitHub Desktop.
Save isterin/76face44fb02fdb024aa0a7ca6579e32 to your computer and use it in GitHub Desktop.
Example R Integration
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