import_inv | R Documentation |
The import_inv
function imports macroinvertebrate sampling data from the Environment Agency's Ecology and Fish Data Explorer (EDE). The data can either be downloaded automatically in .parquet or .csv format, or read in from a previously saved .csv or .rds file. The data can be optionally filtered by site ID and sample date, and the filtered data saved as a .rds file.
import_inv(source = "parquet", sites = NULL, start_date = NULL, end_date = NULL, save = FALSE, save_dwnld = FALSE, save_dir = getwd(), biol_dir = NULL)
source |
Specify source of macroinvertebrate data: "parquet" or "csv" to automatically download data from EDE, or provide path to local .csv, .rds or .parquet file. (Alternatively set |
sites |
Vector of site ids to filter by. |
start_date |
Required start date (in |
end_date |
Required end date (in |
save |
Specifies whether ( |
save_dwnld |
Specifies whether ( |
save_dir |
Path to folder where downloaded and/or filtered data are to be saved. Default = Current working directory. |
biol_dir |
Deprecated. Path to local .csv, .rds or parquet file containing macroinvertebrate data. Default = |
If automatically downloading data from EDE, the parquet file format is faster to download than csv, and has data types pre-formatted.
If saving a copy of the downloaded data, the name of the rds file is hard-wired to INV_OPEN_DATA_METRICS_ALL.RDS
. If saving after filtering on site and/or date, the name of the rds file is hard-wired to INV_OPEN_DATA_METRICS_F.RDS
.
Downloaded raw data files (in .parquet and .csv format) will be automatically removed from the working directory following completed execution of the function.
The function automatically modifies the output from EDE, renaming "SITE_ID" to "biol_site_id" (hetoolkit
's standardised column header for biology site ids).
Tibble containing imported macroinvertebrate data.
# Bulk download of EDE data for all sites in parquet format and save as .rds file for future use:
# import_inv(save_dwnld = TRUE, save_dir = getwd())
# Bulk download of EDE data for all sites in parquet format:
# import_inv(source = "csv")
# Read in local .rds file and filter on selected sites and dates (up to the present day):
# import_inv(source = "data/INV_OPEN_DATA_METRICS_ALL.rds",
# sites = c("34310", "34343"),
# start_date = "1995-01-01",
# end_date = Sys.Date())
# Read in local .csv file, filter on selected sites, and save the result as a .rds file:
# import_inv(source = "data/INV_OPEN_DATA_METRICS.csv",
# sites = c("34310", "34343"),
# save = TRUE,
# save_dir = getwd())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.