From 800dd613d2086dd08aeb8a76a5f8e3c72f76d1a7 Mon Sep 17 00:00:00 2001 From: JTPetter Date: Wed, 8 Jan 2025 16:42:32 +0100 Subject: [PATCH] Fix crash with gauge rr nonrep with some datasets --- R/msaGaugeRRnonrep.R | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/R/msaGaugeRRnonrep.R b/R/msaGaugeRRnonrep.R index 2dd298e0..9da3521a 100644 --- a/R/msaGaugeRRnonrep.R +++ b/R/msaGaugeRRnonrep.R @@ -494,8 +494,11 @@ msaGaugeRRnonrep <- function(jaspResults, dataset, options, ...) { .gaugeNestedVarComponents <- function(dataset, operators, parts, measurements, ms) { nOperators <- length(unique(dataset[[operators]])) - nReplicates <- with(dataset, table(dataset[[operators]], dataset[[parts]]))[1] # assuming constant repetitions across parts and operators - nParts <- as.vector(table(dataset[operators])[1] / nReplicates) + replicatesTable <- table(dataset[[parts]]) + if (!all(replicatesTable == replicatesTable[1])) + stop("Unbalanced design. Some parts have more repeated measurements than others.") + nReplicates <- unname(replicatesTable)[1] # assuming constant repetitions across parts + nParts <- length(unique(dataset[[parts]])) msOperator <- ms[1] msOperatorPart <- ms[2] msRepeat <- ms[3]