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.
Usage
cdmSample(cdm, n, seed = sample.int(1e+06, 1), name = "person_sample")
cdm_sample(cdm, n, seed = sample.int(1e+06, 1), name = "person_sample")
Examples
if (FALSE) { # \dontrun{
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)
} # }