Learn R Programming

SWMPrExtension (version 1.1.7)

update_sampling_stations: Update reserve sampling stations

Description

Script to modify the internal sampling_sites.rda file for adding new reserves or for making changes to existing sampling station locations.

Usage

update_sampling_stations(
  file_path = "inst/extdata",
  file_name = "sampling_stations.csv"
)

Arguments

file_path

path to directory with new file

file_name

name of new csv file

Value

Returns TRUE on a successful run, FALSE on a failure.

Details

This is a standalone function used to replace the internal SWMPrExtension sampling sites data table used by the get_sites.R function. It reads a csv-formatted file of all NERRS SWMP stations that the user has downloaded from the CDMO SWMP station website: https://cdmo.baruch.sc.edu/data/swmp-stations/.

This downloaded csv-formatted file and its location are the only input arguments to update_sampling_station(). The current station information is loaded from data/sampling_stations.rda, a copy of which is written out as data/sampling_stations_backup.rda, and the new data file is read, formatted appropriately, and written out as data/sampling_stations.rda.

Note: This function need only be run when new reserves are added, stations are moved, etc.

Examples

Run this code
# NOT RUN {
# Provide a bad file name to get error message
x <- update_sampling_stations("data","bad_file_name.csv")
print(x)


# Commented out example with a valid, but older, filename.
# WARNING! Don't actually run this example unless you have a
# more recent csv file that can be used to update the rda file.
# x <- update_sampling_stations("inst/extdata","NERRS_sampling_stations.csv")
# print(x)

# }

Run the code above in your browser using DataLab