Learn R Programming

tidywater (version 0.9.0)

modify_water: Modify a single slot in a water class object

Description

This function a single slot of a water class object without impacting the other parameters. For example, you can manually update "tthm" and the new speciation will not be calculated. This function is designed to make sure all parameters are stored in the correct units when manually updating a water. Some slots cannot be modified with this function because they are interconnected with too many others (usually pH dependent, eg, hco3). For those parameters, update define_water.

Usage

modify_water(water, slot, value, units)

modify_water_chain( df, input_water = "defined_water", output_water = "modified_water", slot = "use_col", value = "use_col", units = "use_col" )

Value

A data frame containing columns of selected parameters from a list of water class objects.

modify_water_chain returns a data frame containing a water class column with updated slot

Arguments

water

A water class object

slot

A character string of the slot in the water to modify, eg, "tthm"

value

New value for the modified slot

units

Units of the value being entered, typically one of c("mg/L", "ug/L", "M", "cm-1"). For ions any units supported by convert_units are allowed. For organic carbon, one of "mg/L", "ug/L". For uv254 one of "cm-1", "m-1". For DBPs, one of "ug/L" or "mg/L".

df

a data frame containing a water class column, which has already been computed using define_water_chain

input_water

name of the column of water class data to be used as the input for this function. Default is "defined_water".

output_water

name of the output column storing updated parameters with the class, water. Default is "modified_water".

Examples

Run this code
water1 <- define_water(ph = 7, alk = 100, tds = 100, toc = 5) %>%
  modify_water(slot = "toc", value = 4, units = "mg/L")


library(dplyr)

example_df <- water_df %>%
  define_water_chain() %>%
  modify_water_chain(slot = "br", value = 50, units = "ug/L")

# \donttest{
# Un-comment below to initialize parallel processing
# library(furrr)
# plan(multisession)
example_df <- water_df %>%
  define_water_chain() %>%
  mutate(bromide = rep(c(20, 30, 50), 4)) %>%
  modify_water_chain(slot = "br", value = bromide, units = "ug/L")

# Optional: explicitly close multisession processing
# plan(sequential)
# }

Run the code above in your browser using DataLab