diff --git a/R/aggregate_impute.R b/R/aggregate_impute.R index 1a79790..3478bc0 100644 --- a/R/aggregate_impute.R +++ b/R/aggregate_impute.R @@ -209,6 +209,27 @@ setMethod( } } + if (nrow(data) == 0) { + return( + new( + "aggregatedImputed", + Covariate = data |> + select(!!!grouping) |> + as.data.frame(), + Imputation = ncol(imputation) |> + seq_len() |> + sprintf(fmt = "Imputation%04i") |> + list() |> + c(list(character(0))) |> + rev() |> + matrix( + data = NA_real_, nrow = 0, ncol = ncol(imputation), + byrow = FALSE + ) + ) + ) + } + data |> inner_join(imputation, by = id_column) |> group_by(!!!grouping) |>