From 79fdab27a5219734f0a861f722bff72166d1beeb Mon Sep 17 00:00:00 2001 From: Greg Freedman Ellis Date: Thu, 9 May 2024 12:14:06 -0500 Subject: [PATCH] [187448845]: don't assume that weight in prefs exists --- R/weight.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/weight.R b/R/weight.R index ebd3cb14f..38168d76c 100644 --- a/R/weight.R +++ b/R/weight.R @@ -29,7 +29,13 @@ setMethod("weight", "CrunchDataset", function(x) { # weight. `loadDataset` shouldn't be costly because the dataset is # already cached. full_ds <- loadDataset(datasetReference(x)) - w <- CrunchVariable(allVariables(full_ds)[[w]], filter = activeFilter(x)) + w_var <- allVariables(full_ds)[[w]] + # If the variable doesn't exist return NULL to mimic old backend + # behavior, since we already have everything we need to check + if (is.null(w_var)) { + return(NULL) + } + w <- CrunchVariable(w_var, filter = activeFilter(x)) } return(w) })