Get all unique values from variables that are available within a data frame or a list of dataframes.
Examples
list_with_data <- list(
data.frame(
"Sites" = c("site_1", "site_3", "site_4"),
"ID" = c("subj_1", "subj_5", "subj_8")
),
data.frame(
"Sites" = c("site_1", "site_3", "site_9"),
"ID" = c("subj_7", "subj_9", NA_character_)
)
)
get_unique_vars(list_with_data, c("Sites", "ID"))
#> Sites ID
#> 1 site_1 subj_1
#> 2 site_3 subj_5
#> 3 site_4 subj_8
#> 4 site_1 subj_7
#> 5 site_3 subj_9
#> 6 site_9 <NA>