From 5d3b413997bcdd0cce10e8b29242eb0cfd954741 Mon Sep 17 00:00:00 2001 From: Emi Tanaka Date: Sat, 11 Nov 2023 13:12:07 +1100 Subject: [PATCH] fix issue where more than one nesting unit with no crossing unit --- R/assign.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/assign.R b/R/assign.R index aaca0f8..64044f4 100644 --- a/R/assign.R +++ b/R/assign.R @@ -128,7 +128,13 @@ assign_trts <- function(.edibble, order = "random", seed = NULL, constrain = nes permute_parent_one_alg(vparents, units_df, ntrts) } else { vnparents <- prov$fct_id_parent(id = unit_id, role = "edbl_unit", type = "nest") - permute_parent_more_than_one(setdiff(vparents, vnparents), units_df, ntrts, nparents = vnparents) + vcparents <- setdiff(vparents, vnparents) + if(length(vcparents)) { + permute_parent_more_than_one(setdiff(vparents, vnparents), units_df, ntrts, nparents = vnparents) + } else { + units_df$`0` <- do.call(paste, units_df[as.character(vnparents)]) + permute_parent_one_alg(0, units_df, ntrts) + } } } },