Closed nmercadeb closed 2 months ago
con <- DBI::dbConnect( duckdb::duckdb(), dbdir = CDMConnector::eunomia_dir() ) cdm <- CDMConnector::cdmFromCon( con, cdmSchema = "main", writeSchema = c(prefix = "my_study_", schema = "main") ) #> Note: method with signature 'DBIConnection#Id' chosen for function 'dbExistsTable', #> target signature 'duckdb_connection#Id'. #> "duckdb_connection#ANY" would also be valid cdm <- omopgenerics::insertTable( cdm, "table", dplyr::tibble( subject_id = c(4, 4, 4, 1, 1) |> as.integer(), cohort_start_date = as.Date(c("1997-10-22", "1998-01-01", "1999-01-01", "2001-03-30", "2002-01-01")), cohort_end_date = as.Date(c("1997-10-22", "1998-01-01", "1999-01-01", "2001-03-30", "2002-01-01")), cohort_definition_id = 1:5 |> as.integer() ) ) set <- dplyr::tibble( target_cohort_definition_id = 1L, cohort_name = paste0("cohort_1_", 1997:2002), year = 1997:2002, target_cohort_name = "cohort_1", cohort_definition_id = 1:6 |> as.integer() ) att <- dplyr::tibble( cohort_definition_id = 1:6 |> as.integer(), number_records = 4L, number_subjects = 3L, reason_id = 1L, reason = "Initial qualifying events" |> glue::glue(), excluded_records = 0L, excluded_subjects = 0L ) cohort <- cdm$table |> dplyr::compute(name = "table", temporary = FALSE) |> omopgenerics::newCohortTable( cohortSetRef = set, cohortAttritionRef = att, cohortCodelistRef = NULL, .softValidation = TRUE ) #> Warning: ! 1 casted column in table (cohort_attrition) as do not match expected column #> type: #> • `NA` from to #> Error in `dplyr::mutate()`: #> ℹ In argument: `NA = NULL(.data[["NA"]])`. #> Caused by error: #> ! attempt to apply non-function
Created on 2024-08-13 with reprex v2.1.1
Created on 2024-08-13 with reprex v2.1.1