From d5c3ebbc8168cf226b717a6bb7d4bf8f0ce225d1 Mon Sep 17 00:00:00 2001 From: James Azam Date: Wed, 1 Nov 2023 21:08:44 +0000 Subject: [PATCH] Use rlang arg_match() to prevent partial match --- NAMESPACE | 1 + R/checks.R | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 7255a22db..d168b9b8f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -198,6 +198,7 @@ importFrom(purrr,safely) importFrom(purrr,transpose) importFrom(purrr,walk) importFrom(rlang,abort) +importFrom(rlang,arg_match) importFrom(rlang,cnd_muffle) importFrom(rlang,warn) importFrom(rstan,expose_stan_functions) diff --git a/R/checks.R b/R/checks.R index 96898c2db..ab08fe691 100644 --- a/R/checks.R +++ b/R/checks.R @@ -24,13 +24,14 @@ check_reports_valid <- function(reports, model) { # Check that the case time series (reports) is a data frame assert_data_frame(reports) # Perform checks depending on the model to the data is meant to be used with - model <- match.arg( - model, - c("estimate_infections", - "estimate_truncation", - "estimate_secondary" - ) + model <- arg_match( + model, + values = c( + "estimate_infections", + "estimate_truncation", + "estimate_secondary" ) + ) if (model == "estimate_secondary") { # Check that reports has the right column names