Throws an error if file already exists and overwrite = FALSE, or warns
(and proceeds) if it exists and overwrite = TRUE. Used as a pre-flight
guard before writing report outputs, so a re-render cannot silently
clobber a prior analysis run.
Usage
check_file_exists(file, overwrite = FALSE)
Arguments
- file
Path to the file to check, full path.
- overwrite
Logical; whether to allow overwriting an existing file.
Examples
if (FALSE) { # \dontrun{
check_file_exists("3_results/all/pep_all.csv", overwrite = FALSE)
} # }