Given a master dataframe with at least four columns, creates alias stations. Each row contains instructions needed for creating a single non-primary alias. See params list below for required rows.

If this function runs into an error for a single row, it will log that error in the logfile and the return value and continue to the next row of the master dataframe.

make_new_alias(master_df)

Arguments

master_df

A dataframe that should contain at least four columns: station, station_type, new_alias_name, alias_type. station_name and station_type params are needed to acquire the station's ID. See below for details.

station_name: the name of the primary alias of the monitoring location to which you'd like to add a new alias. See the Location column of get_wq_locations_list for list of existing primary station names.

station_type: the type of the station to which you'd like to add an alias. Can be either continuous or discrete.

alias_type: type of alias. Must be either "secondary", "qaqc"," or "depth" Currently this function only supports secondary or qaqc. A new primary alias of a station can be made using make_new_primary_alias. Depth aliases will be added in here if needed in the future.

new_alias_name: a string of the name for the alias you'd like to create.

TODO: Future versions can accept station_ids which would make this run faster, but is not a priority since typically station names are easier for users than IDs.

Value

Original master_df with a new result column describing the result of the request. If successful, the value will be success. If the new_alias_name is found to exist as an alias for any other station type, it will state that. If the another error has occurred, it will state that as well.

Examples

  # Example master_df
  master_df_example <- data.frame(
    station_name = c("Station1", "Station2"),
    new_alias_name = c("Alias1", "Alias2"),
    station_type = c("discrete", "continuous"),
    alias_type = c("secondary", "qaqc")
  )

  # Call the make_new_alias function
  new_aliases <- make_new_alias(master_df = master_df_example)

  # View the results
  print(new_aliases)