powered by
This is a shorthand of x[file.exists(x)], and optionally returns the first existing file path.
x[file.exists(x)]
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.
TRUE
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.
first = TRUE
xfun::existing_files(c("foo.txt", system.file("DESCRIPTION", package = "xfun")))
Run the code above in your browser using DataLab