This function drops all unspecified variables. It will throw and error if the dataset does not contain all expected variables.
Examples
library(metacore)
library(haven)
library(dplyr)
load(metacore_example("pilot_ADaM.rda"))
spec <- metacore %>% select_dataset("ADSL")
data <- read_xpt(metatools_example("adsl.xpt")) %>%
select(USUBJID, SITEID) %>%
mutate(foo = "Hello")
drop_unspec_vars(data, spec)
#> The following variable(s) were dropped:
#> foo
#> # A tibble: 254 × 2
#> USUBJID SITEID
#> <chr> <chr>
#> 1 01-701-1015 701
#> 2 01-701-1023 701
#> 3 01-701-1028 701
#> 4 01-701-1033 701
#> 5 01-701-1034 701
#> 6 01-701-1047 701
#> 7 01-701-1097 701
#> 8 01-701-1111 701
#> 9 01-701-1115 701
#> 10 01-701-1118 701
#> # ℹ 244 more rows