aou_concept_set {allofus} | R Documentation |
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 |
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
( |
... |
further arguments passed along to |
con |
Connection to the allofus SQL database. Defaults to
|
Value
A dataframe if collect = TRUE
; a reference to a remote database
table if not.
Examples
# indicator for any aspirin at any time
aspirin_users <- aou_concept_set(dplyr::tbl(con, "person"),
concepts = 1191, concept_set_name = "aspirin", domains = "drug"
)
# starting with person table to create a cohort
people <- dplyr::tbl(con, "person") %>%
dplyr::filter(person_id < 2000000) %>%
dplyr::mutate(
start = as.Date("2021-01-01"),
end = as.Date("2023-12-31")
)
dat <- aou_concept_set(
cohort = people,
concepts = c(725115, 1612146, 1613031),
start_date = "start",
end_date = "end",
concept_set_name = "CGM",
output = "all"
)