Skip to content

Commit ea692bc

Browse files
committed
Make sure issue_date is always the last col
1 parent f2b6c80 commit ea692bc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

facebook/contingency-combine.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,19 @@ combine_tables <- function(seen_file, input_dir, input_files, output_file) {
118118
county_fips = col_character()
119119
)
120120

121-
# Get input data.
121+
# Get input data. Make sure `issue_date` is last column after combining.
122122
input_df <- map_dfr(
123123
file.path(input_dir, input_files),
124124
function(f) {
125125
read_csv(f, col_types = cols)
126-
}
127-
)
126+
}) %>%
127+
relocate(issue_date, .after=last_col())
128128

129129
if (file.exists(output_file)) {
130130
output_names <- names(read_csv(output_file, n_max = 0L))
131131
assert(identical(output_names, names(input_df)),
132132
paste0("Column names and/or order differ between new and old input for ", output_file))
133-
}
133+
}
134134

135135
seen_files <- load_seen_file(seen_file)
136136
any_prev_seen <- any(input_files %in% seen_files)
@@ -163,6 +163,7 @@ combine_tables <- function(seen_file, input_dir, input_files, output_file) {
163163
# which is a stable sort, ties will result in the input data being used in
164164
# preference over the existing rollup data.
165165
output_df <- bind_rows(output_df, input_df) %>%
166+
relocate(issue_date, .after=last_col()) %>%
166167
arrange(issue_date) %>%
167168
group_by(across(all_of(group_names))) %>%
168169
slice_tail() %>%

0 commit comments

Comments
 (0)