@@ -118,19 +118,19 @@ combine_tables <- function(seen_file, input_dir, input_files, output_file) {
118
118
county_fips = col_character()
119
119
)
120
120
121
- # Get input data.
121
+ # Get input data. Make sure `issue_date` is last column after combining.
122
122
input_df <- map_dfr(
123
123
file.path(input_dir , input_files ),
124
124
function (f ) {
125
125
read_csv(f , col_types = cols )
126
- }
127
- )
126
+ }) % > %
127
+ relocate( issue_date , .after = last_col() )
128
128
129
129
if (file.exists(output_file )) {
130
130
output_names <- names(read_csv(output_file , n_max = 0L ))
131
131
assert(identical(output_names , names(input_df )),
132
132
paste0(" Column names and/or order differ between new and old input for " , output_file ))
133
- }
133
+ }
134
134
135
135
seen_files <- load_seen_file(seen_file )
136
136
any_prev_seen <- any(input_files %in% seen_files )
@@ -163,6 +163,7 @@ combine_tables <- function(seen_file, input_dir, input_files, output_file) {
163
163
# which is a stable sort, ties will result in the input data being used in
164
164
# preference over the existing rollup data.
165
165
output_df <- bind_rows(output_df , input_df ) %> %
166
+ relocate(issue_date , .after = last_col()) %> %
166
167
arrange(issue_date ) %> %
167
168
group_by(across(all_of(group_names ))) %> %
168
169
slice_tail() %> %
0 commit comments