checkfile: check whether files exist

Description Usage Arguments Details Value Author(s) Examples

View source: R/checkfile.R

Description

Check whether files exist (or don't exist), and stop()

Usage

1
checkfile(..., invert = FALSE)

Arguments

...

files to check

invert

check for existence of a file, instead of non-existence

Details

I often want to run a script only if a particular file or files already exist. Or perhaps only run a script if the output file doesn't already exist. To avoid writing a lot of =if(file.exists(f)) = this is a convenience function.

Value

no return value

Author(s)

Chris Wallace

Examples

1
2
3
4
5
6
## Should do nothing
checkfile(system.file(c("INDEX","help")))
checkfile(system.file(c("ThisFileShouldNotExist")),invert=TRUE)
## Should call stop()
checkfile(system.file(c("INDEX","help")),invert=TRUE)
checkfile(system.file(c("ThisFileShouldNotExist")))

chr1swallace/random-functions documentation built on March 6, 2021, 10:56 a.m.