This function is used to extract a common value based on names order.
Please see Details section for more information.
Details
This function is used to extract a common value from a list object based on
pre-specified name order. The first non-missing value will be considered as
a common value. Otherwise, a missing value 'NA' will be assigned.
Examples
# Example data
col_order <- c("ADASQ4SCORE", "MMSE", "LDELTOTL", "DIGITSCR", "TRABSCOR")
example_data <- tibble::tibble(
SCORE_SOURCE = col_order,
VISCODE2 = c("bl", "sc", "bl", "bl", "bl")
)
list_value <- deframe_as_list(
x = example_data,
col_names = c("SCORE_SOURCE", "VISCODE2")
)
get_common_value(
list_value = list_value,
col_order = col_order
)
#> [1] "bl"
# List with missing value
list_value2 <- list(
ADASQ4SCORE = "bl",
MMSE = NA,
LDELTOTL = "bl",
DIGITSCR = NA,
TRABSCOR = "bl"
)
get_common_value(
list_value = list_value2,
col_order = col_order
)
#> [1] "bl"
