% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/loadDataFile.R
\name{loadDataFile}
\alias{loadDataFile}
\title{Load R data from a URL or local file}
\usage{
loadDataFile(
  filename = NULL,
  dataUrl = NULL,
  dataDir = NULL,
  priority = c("dataDir", "dataUrl")
)
}
\arguments{
\item{filename}{Name of the \code{.rda} file to load.}

\item{dataUrl}{Remote URL directory containing data files.}

\item{dataDir}{Local directory containing data files.}

\item{priority}{First data source to try when both \code{dataDir} and \code{dataUrl}
are supplied.}
}
\value{
Object loaded from the \code{.rda} file.
}
\description{
Load a pre-generated R binary data file from either a local directory or a
remote URL.
}
\details{
This function is intended for use by package-level \verb{*_load()} helper
functions. It allows locally cached data files to be used when available,
avoiding unnecessary internet access.

If both \code{dataDir} and \code{dataUrl} are provided, \code{priority} determines which
source is tried first. If loading from the first source fails, the other
source is used as a fallback.
}
\examples{
\dontrun{
filename <- "USCensusStates_02.rda"
dataDir <- "~/Data/Spatial"
dataUrl <- "http://data.mazamascience.com/MazamaSpatialUtils/Spatial_0.8"

# Load local file
USCensusStates <- loadDataFile(filename, dataDir = dataDir)

# Load remote file
USCensusStates <- loadDataFile(filename, dataUrl = dataUrl)

# Load local file with remote file as backup
USCensusStates <- loadDataFile(
  filename,
  dataDir = dataDir,
  dataUrl = dataUrl,
  priority = "dataDir"
)

# Load remote file with local file as backup
USCensusStates <- loadDataFile(
  filename,
  dataDir = dataDir,
  dataUrl = dataUrl,
  priority = "dataUrl"
)
}

}
