Skip to contents

Fetch and convert data from rems to AquaChem format

Usage

rems_to_aquachem(
  ems_ids,
  date_range = NULL,
  save = TRUE,
  out_folder = "./",
  out_file = NULL,
  interactive = TRUE,
  dont_update = TRUE
)

Arguments

ems_ids

Character vector. Unique EMS ids

date_range

Character vector. Start and end dates (YYYY-MM-DD)

save

Logical. Whether or not to save the data as csv.

out_folder

Character. Where to save data for AquaChem

out_file

Character. What to call data file for AquaChem. Default is aquachem_DATE.csv

interactive

Logical. Whether or not to ask when caching data.

dont_update

Logical. Whether or not to avoid updating EMS if interactive is FALSE

Value

Outputs an Excel and a CSV file in the format to import into AquaChem.

Details

out_folder This is how you tell the function where to store the aquachem data.

Examples

if (FALSE) {
# Convert one well and save the data in the working directory
rems_to_aquachem(ems_ids = "E289551")

# Convert several wells (this will overwrite the previous data!)
rems_to_aquachem(ems_ids = c("1401030", "1401377"))

# To specify a date range (Year-Month-Day)
rems_to_aquachem(ems_ids = c("1401030", "1401377"),
                 date_range = c("2000-01-01", "2015-01-01"))

# To name the ouput (extension should be .csv, .txt, or .dat)
rems_to_aquachem(ems_ids = "1401030", out_file = "water_quality01.csv")

# To save the output to a specific folder
# (here, the Outputs folder in the Rcode folder on the H drive)
# Note that the out_folder must exist or you'll get an error
rems_to_aquachem(ems_ids = c("1401030", "1401377"),
                 out_folder = "H:\\Rcode\\Outputs/")

# All together now!
rems_to_aquachem(ems_ids = c("1401030", "1401377"),
                 date_range = c("2000-01-01", "2015-01-01"),
                 out_file = "water_quality05.csv",
                 out_folder = "H:\\Rcode\\Outputs/")

# Clean up
unlink("water_quality01.csv")
unlink(paste0("aquachem_", Sys.Date(), ".csv"))
}