library("allofus")
# indicator for any aspirin at any time
<- aou_concept_set(dplyr::tbl(con, "person"),
aspirin_users concepts = 1191, concept_set_name = "aspirin", domains = "drug"
)
# starting with person table to create a cohort
<- dplyr::tbl(con, "person") %>%
people ::filter(person_id < 2000000) %>%
dplyr::mutate(
dplyrstart = as.Date("2021-01-01"),
end = as.Date("2023-12-31")
)
<- aou_concept_set(
dat cohort = people,
concepts = c(725115, 1612146, 1613031),
start_date = "start",
end_date = "end",
concept_set_name = "CGM",
output = "all"
)
Get occurrences of a concept set from AoU for a given cohort
Description
Retrieves occurrences of a concept set from the All of Us database for a given cohort.
Usage
aou_concept_set(
cohort = NULL,
concepts,
start_date = NULL,
end_date = NULL,
domains = c("condition", "measurement", "observation", "procedure", "drug", "device",
"visit"),
output = "indicator",
concept_set_name = "concept_set",
min_n = 1,
collect = FALSE,
...,
con = getOption("aou.default.con")
)
Arguments
cohort
|
Reference to a remote table or local dataframe with a column called "person_id", and (possibly) columns for start_date and end_date . If not provided, defaults to entire All of Us cohort.
|
concepts
|
a vector of concept ids |
start_date
|
chr; the name of the start_date column in the cohort table; defaults to NULL to pull data across all dates |
end_date
|
chr; the name of the end_date column in the cohort table; defaults to NULL to pull data across all dates |
domains
|
chr; a vector of domains to search for the concepts in ("condition", "measurement", "observation", "procedure", "drug", "device", "visit"); defaults to all |
output
|
one of "indicator", "count", "all"; do you want to return a 1 if a person has any matching concepts and 0 if not ("indicator"), the number of matching concepts per person ("count"), or all info about the matching concepts ("all"). Defaults to "indicator" |
concept_set_name
|
chr; If output = "indicator" or output = "n", name for that column. Defaults to "concept_set". |
min_n
|
dbl; If output = "indicator", the minimum number of occurrences per person to consider the indicator true. Defaults to 1. |
collect
|
Whether to bring the resulting table into local memory (collect = TRUE ) as a dataframe or leave as a reference to a database table (for continued analysis using, e.g., dbplyr ). Defaults to FALSE.
|
…
|
further arguments passed along to collect() if collect = TRUE
|
con
|
Connection to the allofus SQL database. Defaults to getOption(“aou.default.con”) , which is created automatically with aou_connect() .
|
Value
A dataframe if collect = TRUE
; a reference to a remote database table if not.