Skip to contents

Connects to the All of Us database and returns a BigQueryConnection object. You can reference this object to query the database using R and or SQL code. A message is printed with the connection status (successful or not).

Usage

aou_connect(CDR = getOption("aou.default.cdr"), ...)

Arguments

CDR

The name of the "curated data repository" to connect to. Defaults to getOption("aou.default.cdr"), which is Sys.getenv('WORKSPACE_CDR') if not specified otherwise (i.e., the "mainline" CDR). On the controlled tier, specify the "base" CDR with CDR = paste0(Sys.getenv('WORKSPACE_CDR'), "_base").

...

Further arguments passed along to DBI::dbConnect().

Value

A BigQueryConnection object. This object is also saved as an option (getOption("aou.default.con")).

Details

You can reference this object to connect to the All of Us database and run SQL code using, e.g., dbplyr or DBI. A message is printed with the connection status (successful or not).

Examples

if (FALSE) { # on_workbench()
con <- aou_connect()
# reference the observation table in the database
dplyr::tbl(con, "observation")
# print a list of the tables in the database
DBI::dbListTables(con)
}