record_problems <- function(x, path, label) { if (nrow(problems(x)) == 0) { return(invisible()) } problem_dir <- here::here("..", "problems") problem_path <- path(problem_dir, label, ext = "csv") dir_create(problem_dir) write_csv(problems(x), problem_path, append = file_exists(problem_path)) }