Attempt to list all columns in the database and group the ones that are common to some datasets. Useful to find keys to pivot or summarise data.
Usage
get_common_cols(lookup = edc_lookup(), min_datasets = 3)
# S3 method for class 'common_cols'
summary(object, ...)
Arguments
- lookup
the lookup table, default to
edc_lookup()
- min_datasets
the minimal number of datasets to be considered
- object
an object of class "common_cols"
- ...
unused
Examples
tm = edc_example()
#> Warning: Option "edc_lookup" has been overwritten.
load_list(tm)
x = get_common_cols(min_datasets=1)
x
#> # A tibble: 27 × 7
#> column name_in datasets n_datasets pct_datasets datasets_in datasets_out
#> <chr> <list> <list> <int> <dbl> <chr> <chr>
#> 1 crfname <lgl [8]> <chr [8]> 8 1 enrol, db2,… ""
#> 2 subjid <lgl [8]> <chr [8]> 8 1 enrol, db2,… ""
#> 3 aegr <lgl [8]> <chr [1]> 1 0.125 ae "enrol, db2…
#> 4 aesoc <lgl [8]> <chr [1]> 1 0.125 ae "enrol, db2…
#> 5 age <lgl [8]> <chr [1]> 1 0.125 enrol "db2, db3, …
#> 6 arm <lgl [8]> <chr [1]> 1 0.125 enrol "db2, db3, …
#> 7 date1 <lgl [8]> <chr [1]> 1 0.125 db1 "enrol, db2…
#> 8 date10 <lgl [8]> <chr [1]> 1 0.125 db3 "enrol, db2…
#> 9 date2 <lgl [8]> <chr [1]> 1 0.125 db1 "enrol, db2…
#> 10 date3 <lgl [8]> <chr [1]> 1 0.125 db1 "enrol, db2…
#> # ℹ 17 more rows
summary(x)
#> # A tibble: 2 × 7
#> pct_datasets n_datasets n_distinct_datasets n_columns columns datasets
#> <chr> <int> <int> <int> <list> <list>
#> 1 100% 8 1 2 <chr [2]> <list [2]>
#> 2 12% 1 8 25 <chr [25]> <list [25]>
#> # ℹ 1 more variable: columns_str <chr>