Retrieve and Load Datasets
get_data.Rd
The get_data
function is designed to load specific datasets from the
appliedepidata
package based on search criteria such as name
, language
,
group_identifier
, or unique_identifier
. The function performs an internal
lookup to identify the appropriate dataset(s), then loads and assigns them into
the global environment.
Depending on the type of dataset (e.g., regular data frame, spatial data (sf
),
or list), appropriate post-processing is done to ensure proper handling and
loading.
Usage
get_data(
name = NULL,
language = NULL,
group_identifier = NULL,
usage = NULL,
unique_identifier = NULL
)
Arguments
- name
(optional) A string specifying the name of the dataset to load.
- language
(optional) A string specifying the language of the dataset. If used with
name
,group_identifier
, orunique_identifier
, the function will filter datasets based on this language.- group_identifier
(optional) A string identifying a group of related datasets. If provided, the function will return all datasets within the group unless further criteria are given.
- usage
(optional) A string representing where the datasets are used. If provided, the function will return all datasets within the group unless further criteria are given.
- unique_identifier
(optional) A string representing the unique identifier for a dataset.
Value
The dataset(s) are loaded into the global environment. Depending on the structure #' of the dataset, it could be a data frame, spatial object, or individual list elements loaded as separate objects.
Details
The function operates as follows:
Dataset Lookup: It performs an internal lookup to identify datasets matching the search criteria provided.
Loading Datasets: For each dataset found:
It attempts to load the dataset using the
data()
function from theappliedepidata
package.The dataset is loaded into a temporary environment to avoid global environment clutter during the loading process.
Post-Processing Based on Object Type: Once the dataset is loaded, the function checks the type of object and handles it accordingly:
Data frames are directly assigned to the global environment without any further processing.
Phylo objects (
phylo
class) are directly assigned to the global environment without any further processing.Stars objects (
stars
class) are directly assigned to the global environment without any further processing.Epinow objects (
epinow
class) are directly assigned to the global environment without any further processing.Spatial objects (
sf
class) are processed usingsf::st_as_sf()
to ensure correct handling of spatial data, and then assigned to the global environment.Lists that are not data frames are split into individual objects and assigned to the global environment as separate entities.
If any dataset cannot be found or loaded, the function will raise an error.
See also
appliedepidata::search_data()
for details on finding datasets and their criteria.