cdmSample {CDMConnector} | R Documentation |
cdmSample
takes a cdm object and returns a new cdm that includes only a
random sample of persons in the cdm. Only person_id
s in both the person
table and observation_period table will be considered.
cdmSample(cdm, n)
cdm_sample(cdm, n)
cdm |
A cdm_reference object |
n |
Number of persons to include in the cdm |
A modified cdm_reference object where all clinical tables are lazy queries pointing to subset
## Not run:
library(CDMConnector)
library(dplyr, warn.conflicts = FALSE)
con <- DBI::dbConnect(duckdb::duckdb(), eunomia_dir())
cdm <- cdm_from_con(con, cdm_schema = "main")
cdmSampled <- cdmSample(cdm, n = 2)
cdmSampled$person %>%
select(person_id)
#> # Source: SQL [2 x 1]
#> # Database: DuckDB 0.6.1
#> person_id
#> <dbl>
#> 1 155
#> 2 3422
DBI::dbDisconnect(con, shutdown = TRUE)
## End(Not run)