Skip to contents

Main function that updates several FRS datasets for use in EJAM

Usage

frs_update_datasets(
  folder = NULL,
  folder_save_as_arrow = ".",
  downloaded_and_unzipped_already = FALSE,
  csvname = "NATIONAL_SINGLE.CSV",
  save_as_arrow_frs = TRUE,
  save_as_arrow_frs_by_programid = TRUE,
  save_as_arrow_frs_by_naics = TRUE,
  save_as_arrow_frs_by_sic = TRUE,
  save_as_arrow_frs_by_mact = TRUE,
  save_as_data_frs = FALSE,
  save_as_data_frs_by_programid = FALSE,
  save_as_data_frs_by_naics = FALSE,
  save_as_data_frs_by_sic = FALSE,
  save_as_data_frs_by_mact = FALSE,
  date = Sys.Date()
)

Arguments

folder

optional folder for where to download to; uses temp folder by default

folder_save_as_arrow

optional folder where to save any .arrow files

downloaded_and_unzipped_already

optional, set to TRUE if already downloaded latest and folder will be specified or can be assumed to be current working directory

csvname

optional, passed to frs_get()

save_as_arrow_frs

Whether to save frs.arrow in folder_save_as_arrow.

save_as_arrow_frs_by_programid

Whether to save frs_by_programid.arrow there.

save_as_arrow_frs_by_naics

Whether to save frs_by_naics.arrow there.

save_as_arrow_frs_by_sic

Whether to save frs_by_sic.arrow there.

save_as_arrow_frs_by_mact

Whether to save frs_by_mact.arrow there.

save_as_data_frs, save_as_data_frs_by_programid, save_as_data_frs_by_naics, save_as_data_frs_by_sic, save_as_data_frs_by_mact

Obsolete. FRS tables are no longer saved as .rda files in ./data/. Leave these as FALSE and publish the .arrow files instead.

date

Retrieval/snapshot date passed to frs_get(). Set it to the original retrieval date when reusing a previously downloaded source CSV.

Value

Writes the requested Arrow IPC files locally, using frs_get() and frs_inactive_ids() and other functions, and invisibly returns the newly built frs table. The caller must validate and publish the files. download_date and released describe this FRS retrieval/snapshot; the version and release-date attributes come from EJAM's DESCRIPTION.

Details

This function is used by someone maintaining the EJAM package, to obtain updated Facility Registry Service (FRS) data such as the locations, IDs, etc. for hundreds of thousands of EPA-regulated sites.

This function is only for a package maintainer/updater (or an analyst who wants to get the latest information).

These datasets are obtained from EPA servers, reformatted for this package, and written as local Arrow IPC files for validation before they are uploaded to an ejamdata release - see updating data for package. The save_as_data_* parameters are obsolete and kept only to make old maintainer scripts fail clearly. FRS tables are no longer saved as lazy-loaded .rda package data in EJAM/data/.

The five FRS Arrow files are frs, frs_by_programid, frs_by_naics, frs_by_sic, and frs_by_mact. The function also writes mact_table.arrow and mact_table.rda to the output folder; mact_table is package data, not one of the 11 dynamic Arrow release assets. The Arrow files later get downloaded for local use by EJAM.