Skip to content

Commit be1e2b1

Browse files
committed
drop aggregation if any relevant col is all NA
1 parent 5891f72 commit be1e2b1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

facebook/delphiFacebook/R/contingency_aggregate.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,12 @@ post_process_aggs <- function(df, aggregations, cw_list) {
158158
metric_cols <- unique(aggregations$metric)
159159

160160
cols_check_available <- unique(c(group_vars[group_vars != "geo_id"], metric_cols))
161-
available <- cols_check_available %in% names(df)
161+
available <- unlist(
162+
lapply(cols_check_available, function(col) {
163+
# Exists in dataframe and column is not only NAs
164+
col %in% names(df) && !all(is.na( unique(df[[col]] )))
165+
})
166+
)
162167
cols_not_available <- cols_check_available[ !available ]
163168
for (col_var in cols_not_available) {
164169
# Remove from aggregations

0 commit comments

Comments
 (0)