This is a shorthand of x[file.exists(x)]
, and optionally returns the
first existing file path.
existing_files(x, first = FALSE, error = TRUE)
A vector of existing file paths.
A vector of file paths.
Whether to return the first existing path. If TRUE
and no
specified files exist, it will signal an error unless the argument
error = FALSE
.
Whether to throw an error when first = TRUE
but no files
exist. It can also take a character value, which will be used as the error
message.
xfun::existing_files(c("foo.txt", system.file("DESCRIPTION", package = "xfun")))
Run the code above in your browser using DataLab