From 56ab6d33fb701de1b98c27f812b09883dce4b73c Mon Sep 17 00:00:00 2001 From: Stef van Buuren Date: Mon, 12 Aug 2024 16:28:58 +0200 Subject: [PATCH] Warn, but return the default reference when the key-population combination is not found --- R/get_reference.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/get_reference.R b/R/get_reference.R index 67768bf..59986be 100644 --- a/R/get_reference.R +++ b/R/get_reference.R @@ -70,8 +70,11 @@ get_reference <- function(population = NULL, # filter references idx <- which(references$key == key & references$population == population) if (!any(idx)) { - warning("Reference '", population, "' for key '", key, "' not found.", + # use default reference if not found + warning("Reference '", population, "' for key '", key, "' not found. Using default.", call. = FALSE) + idx <- which(references$key == "gsed2406" & + references$population == "preliminary_standards") } return(references[idx, ]) }