Skip to content

Commit 4b445bc

Browse files
committed
Sort output by date; comment cleanup
1 parent e43fc13 commit 4b445bc

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

facebook/contingency-combine.R

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env Rscript
22

3-
## Combine and compress contingency tables by aggregation.
3+
## Combine and compress contingency tables by grouping variable set.
44
##
55
## Usage:
66
##
@@ -45,13 +45,12 @@ run_rollup <- function(input_dir, output_dir, pattern = "^[0-9]{8}_[0-9]{8}.*[.]
4545
seen_files <- load_seen_file(seen_file)
4646

4747
for (output_name in names(files)) {
48-
browser
4948
newly_seen_files <- combine_and_save_tables(
5049
seen_files,
5150
input_dir,
5251
files[[output_name]],
5352
file.path(output_dir, output_name))
54-
browser()
53+
5554
write(newly_seen_files, seen_file, append=TRUE)
5655
}
5756

@@ -138,8 +137,8 @@ combine_and_save_tables <- function(seen_files, input_dir, input_files, output_f
138137
write_csv(input_df, output_file, append=file.exists(output_file))
139138
} else {
140139
assert(file.exists(output_file),
141-
paste0("The output file ", output_file, " does not exist, but ",
142-
"non-zero files using the same grouping have been seen before."))
140+
paste0("The output file ", output_file, " does not exist, but non-zero",
141+
" files using the same grouping variables have been seen before."))
143142

144143
output_df <- read_csv(output_file, col_types = cols)
145144

@@ -158,9 +157,11 @@ combine_and_save_tables <- function(seen_files, input_dir, input_files, output_f
158157
arrange(issue_date) %>%
159158
group_by(across(all_of(group_names))) %>%
160159
slice_tail() %>%
161-
ungroup()
160+
ungroup() %>%
161+
arrange(period_start)
162162

163-
# Automatically uses gzip compression based on output file name.
163+
# Automatically uses gzip compression based on output file name. Overwrites
164+
# existing file of the same name.
164165
write_csv(output_df, output_file)
165166
}
166167

0 commit comments

Comments
 (0)