@@ -55,7 +55,7 @@ produce_aggregates <- function(df, aggregations, cw_list, params) {
55
55
56
56
agg_groups <- unique(aggregations [c(" group_by" , " geo_level" )])
57
57
58
- # For each unique combination of groupby_vars and geo level, run aggregation process once
58
+ # For each unique combination of group_vars and geo level, run aggregation process once
59
59
# and calculate all desired aggregations on the grouping. Rename columns. Save
60
60
# to individual files
61
61
for (group_ind in seq_along(agg_groups $ group_by )) {
@@ -248,16 +248,16 @@ summarize_aggs <- function(df, crosswalk_data, aggregations, geo_level, params)
248
248
# # inefficient; profiling shows the cost to be negligible, so shut it up
249
249
df <- suppressWarnings(inner_join(df , crosswalk_data , by = " zip5" ))
250
250
251
- groupby_vars <- aggregations $ group_by [[1 ]]
251
+ group_vars <- aggregations $ group_by [[1 ]]
252
252
253
- if (all(groupby_vars %in% names(df ))) {
254
- unique_group_combos <- unique(df [, groupby_vars , with = FALSE ])
253
+ if (all(group_vars %in% names(df ))) {
254
+ unique_group_combos <- unique(df [, group_vars , with = FALSE ])
255
255
unique_group_combos <- unique_group_combos [complete.cases(unique_group_combos )]
256
256
} else {
257
257
msg_plain(
258
258
sprintf(
259
259
" not all of groupby columns %s available in data; skipping aggregation" ,
260
- paste(groupby_vars , collapse = " , " )
260
+ paste(group_vars , collapse = " , " )
261
261
))
262
262
}
263
263
@@ -268,7 +268,7 @@ summarize_aggs <- function(df, crosswalk_data, aggregations, geo_level, params)
268
268
# # Set an index on the groupby var columns so that the groupby step can be
269
269
# # faster; data.table stores the sort order of the column and
270
270
# # uses a binary search to find matching values, rather than a linear scan.
271
- setindexv(df , groupby_vars )
271
+ setindexv(df , group_vars )
272
272
273
273
calculate_group <- function (ii ) {
274
274
target_group <- unique_group_combos [ii ]
@@ -301,15 +301,15 @@ summarize_aggs <- function(df, crosswalk_data, aggregations, geo_level, params)
301
301
# # Do post-processing.
302
302
for (row in seq_len(nrow(aggregations ))) {
303
303
aggregation <- aggregations $ id [row ]
304
- groupby_vars <- aggregations $ group_by [[row ]]
304
+ group_vars <- aggregations $ group_by [[row ]]
305
305
post_fn <- aggregations $ post_fn [[row ]]
306
306
307
307
dfs_out [[aggregation ]] <- dfs_out [[aggregation ]][
308
- rowSums(is.na(dfs_out [[aggregation ]][, c(" val" , " sample_size" , groupby_vars )])) == 0 ,
308
+ rowSums(is.na(dfs_out [[aggregation ]][, c(" val" , " sample_size" , group_vars )])) == 0 ,
309
309
]
310
310
311
311
if (geo_level == " county" ) {
312
- df_megacounties <- megacounty(dfs_out [[aggregation ]], params $ num_filter , groupby_vars )
312
+ df_megacounties <- megacounty(dfs_out [[aggregation ]], params $ num_filter , group_vars )
313
313
dfs_out [[aggregation ]] <- bind_rows(dfs_out [[aggregation ]], df_megacounties )
314
314
}
315
315
0 commit comments