Skip to content

Commit

Permalink
aggregate_impute() handles cases of aggregatedImputed with joins lead…
Browse files Browse the repository at this point in the history
…ing to empty sets.
  • Loading branch information
ThierryO committed Aug 10, 2023
1 parent 6ca5dc7 commit 5fed6b2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions R/aggregate_impute.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) |>
Expand Down

0 comments on commit 5fed6b2

Please sign in to comment.