This function builds a dataset out of the columns that just need to be pulled through. So any variable that has a derivation in the format of 'dataset.variable' will be pulled through to create the new dataset. When there are multiple datasets present, they will be joined by the shared `key_seq` variables. These columns are often called 'Predecessors' in ADaM, but this is not universal so that is optional to specify.
build_from_derived(
metacore,
ds_list,
dataset_name = NULL,
predecessor_only = TRUE,
keep = FALSE
)metacore object that contains the specifications for the dataset of interest.
Named list of datasets that are needed to build the from. If the list is unnamed,then it will use the names of the objects.
Optional string to specify the dataset that is being built. This is only needed if the metacore object provided hasn't already been subsetted.
By default `TRUE`, so only variables with the origin of 'Predecessor' will be used. If `FALSE` any derivation matching the dataset.variable will be used.
Boolean to determine if the original columns should be kept. By default `FALSE`, so only the ADaM columns are kept. If `TRUE` the resulting dataset will have all the ADaM columns as well as any SDTM column that were renamed in the ADaM (i.e `ARM` and `TRT01P` will be in the resulting dataset)
dataset
library(metacore)
library(haven)
library(magrittr)
load(metacore_example("pilot_ADaM.rda"))
spec <- metacore %>% select_dataset("ADSL")
#> Warning: `core` from the `ds_vars` table only contains missing values.
#> Warning: `supp_flag` from the `ds_vars` table only contains missing values.
#> Warning: `common` from the `var_spec` table only contains missing values.
#> Warning: `where` from the `value_spec` table only contains missing values.
#> Warning: `dataset` from the `supp` table only contains missing values.
#> Warning: `variable` from the `supp` table only contains missing values.
#> Warning: `idvar` from the `supp` table only contains missing values.
#> Warning: `qeval` from the `supp` table only contains missing values.
#> ✔ ADSL dataset successfully selected
#>
ds_list <- list(DM = read_xpt(metatools_example("dm.xpt")))
build_from_derived(spec, ds_list, predecessor_only = FALSE)
#> # A tibble: 306 × 12
#> USUBJID SUBJID SITEID TRT01P AGE AGEU RACE SEX ETHNIC DTHFL RFSTDTC
#> <chr> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 01-701-1015 1015 701 Place… 63 YEARS WHITE F HISPA… "" "2014-…
#> 2 01-701-1023 1023 701 Place… 64 YEARS WHITE M HISPA… "" "2012-…
#> 3 01-701-1028 1028 701 Xanom… 71 YEARS WHITE M NOT H… "" "2013-…
#> 4 01-701-1033 1033 701 Xanom… 74 YEARS WHITE M NOT H… "" "2014-…
#> 5 01-701-1034 1034 701 Xanom… 77 YEARS WHITE F NOT H… "" "2014-…
#> 6 01-701-1047 1047 701 Place… 85 YEARS WHITE F NOT H… "" "2013-…
#> 7 01-701-1057 1057 701 Scree… 59 YEARS WHITE F HISPA… "" ""
#> 8 01-701-1097 1097 701 Xanom… 68 YEARS WHITE M NOT H… "" "2014-…
#> 9 01-701-1111 1111 701 Xanom… 81 YEARS WHITE F NOT H… "" "2012-…
#> 10 01-701-1115 1115 701 Xanom… 84 YEARS WHITE M NOT H… "" "2012-…
#> # ℹ 296 more rows
#> # ℹ 1 more variable: RFENDTC <chr>