R/bdc_standardize_datasets.R
bdc_standardize_datasets.RdThis function's main goal is to merge and standardize different datasets into a new dataset with column names following the Darwin Core terminology. All the process is based on a metadata file provided by the user.
bdc_standardize_datasets(
metadata,
format = "csv",
overwrite = FALSE,
save_database = FALSE
)A data frame with metadata containing information about the name, path, and columns of the original data set which need to be renamed. See @details.
a character setting the output file type. Option available are "csv" and "qs2" (recommenced to save large datasets). Default == "csv".
A logical vector indicating whether the final merged dataset
should be overwritten. The default is FALSE. When FALSE and the merged file
(Output/Intermediate/00_merged_database.<format>) already exists, that
file is read and returned without processing metadata.
logical. Should the standardized database be locally saved? Default = FALSE.
A merged data.frame with column names following Darwin Core
terminology and all columns stored as character. It contains only the
datasets described in metadata; a dataset whose file lacks a column named
in the metadata, or that fails to be read, is excluded and named in a
message. When every dataset is excluded, the function errors and saves
nothing.
bdc_standardize_datasets() facilitate the standardization of datasets with
different column names by converting them into a new dataset following the
Darwin Core terminology. The standardization process relies on a metadata
file containing the name, path, and columns that need to be renamed. The
metadata file can be constructed using built-in functions (e.g.,
data.frame()) or storing the information in a CSV file and importing it
into R. Regardless of the method chosen, the data frame with metadata needs
to contain the following column names (this is a list of required column
names; for a comprehensive list of column names following Darwin Core
terminology, see
here::here (https://brunobrr.github.io/bdc/articles/integrate_datasets.html)
datasetName: A short name identifying the dataset (e.g., GBIF)
fileName: The relative path containing the name of the input dataset
(e.g., Input_files/GBIF.csv)
scientificName: Name of the column in the original database presenting
the taxon scientific names with or without authorship information, depending
on the format of the source dataset (e.g., Myrcia acuminata)
decimalLatitude: Name of the column in the original database presenting
the geographic latitude in decimal degrees (e.g., -6.370833)
decimalLongitude: Name of the column in the original database presenting
the geographic longitude in decimal degrees (e.g., -3.25500)
if (FALSE) { # \dontrun{
metadata <- readr::read_csv(system.file("extdata/Config/DatabaseInfo.csv",
package = "bdc"))
db_standardized <-
bdc_standardize_datasets(
metadata = metadata,
format = "csv",
overwrite = TRUE,
save_database = FALSE)
} # }