Skip to content

Commit

Permalink
Fix warning in writing completeness datasets
Browse files Browse the repository at this point in the history
- Closes #53
  • Loading branch information
jeanpaulrsoucy committed Oct 3, 2023
1 parent d325ebf commit b86bab0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/write_funs.R
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ write_dataset <- function(d, geo, name, ext = "csv") {
# construct path
out_path <- file.path("data", geo, paste(name, ext, sep = "."))
# check maximum date: stop with error if max date is greater than current date
date_max <- max(d$date)
if (ext == "csv") {
date_max <- max(d$date)
} else {
date_max <- max(as.Date(names(d)))
}
if (date_max > get_current_date()) stop(paste0("Failed to write dataset: ", out_path, " (current date is earlier than max date: ", date_max, ")"))
# save file
if (ext == "csv") {
Expand Down

0 comments on commit b86bab0

Please sign in to comment.