# Some subjects are missing an APGR score in the base dataset
xpdb_missing <- pheno_base %>%
mutate_x(APGR = dplyr::if_else(ID %in% c("1", "2"), NA, APGR))
# A separate table with the (complete) values, keyed on ID
apgr_lookup <- xpose::get_data(pheno_base, quiet = TRUE) %>%
dplyr::distinct(ID, APGR)
# Existing APGR values are kept; only the missing ones are filled in
left_join_x(xpdb_missing, apgr_lookup, by = "ID")
Run the code above in your browser using DataLab