Dynamically handle a local or remote file path

localOrRemoteFile(file, quiet = getOption("acid.quiet", default = FALSE))

Arguments

file

character(1). Local file paths or remote URLs.

quiet

logical(1). Perform command quietly, suppressing messages.

Value

character. Local file path(s). Stops on a missing file.

Note

Updated 2020-12-10.

Vectorization

This function is vectorized and supports mixed local and remote paths. Remote files are downloaded locally to a temporary directory.

Compressed files

Compressed files will automatically be decompressed. Currently, these file extensions are natively supported: BZ2, GZ, XZ, and ZIP.

See also

Examples

## Local file <- system.file("extdata/example.csv", package = "pipette") x <- localOrRemoteFile(file) basename(x)
#> [1] "example.csv"
## Remote file <- AcidBase::pasteURL( pipetteTestsURL, "hgnc.txt.gz", protocol = "none" ) x <- localOrRemoteFile(file)
#> → Downloading <https://r.acidgenomics.com/testdata/pipette/v0.5/hgnc.txt.gz> to /private/var/folders/l1/8y8sjzmn15v49jgrqglghcfr0000gn/T/RtmpNWByJh/pipette-131e2bf1c7f0.txt.gz.
#> [1] "pipette-131e2bf1c7f0.txt"