Loads pre-generated R binary (".rda") files from a URL or a local
directory. This function is intended to be called by other ~_load()
functions and can remove internet latencies when local versions of data are
available.
If both dataUrl
and dataDir
are provided, an attempt will be
made to load data from the source specified by priority
with the
other source used as a backup.
loadDataFile(
filename = NULL,
dataUrl = NULL,
dataDir = NULL,
priority = c("dataDir", "dataUrl")
)
Name of the R data file to be loaded.
Remote URL directory for data files.
Local disk directory containing data files.
First data source to attempt if both are supplied.
A data object.
if (FALSE) {
library(MazamaCoreUtils)
filename = "USCensusStates_02.rda"
dir = "~/Data/Spatial"
url = "http://data.mazamascience.com/MazamaSpatialUtils/Spatial_0.8"
# Load local file
USCensusStates = loadDataFile(filename, dataDir = dir)
# Load remote file
USCensusStates = loadDataFile(filename, dataUrl = url)
# Load local file with remote file as backup
USCensusStates =
loadDataFile(filename, dataDir = dir, dataUrl = url, priority = "dataDir")
# Load remote file with local file as backup
USCensusStates =
loadDataFile(filename, dataDir = dir, dataUrl = url, priority = "dataUrl")
}