define_water_chain function

Apply define_water within a dataframe and output a column of water class to be chained to other tidywater functions

Apply define_water within a dataframe and output a column of water class to be chained to other tidywater functions

This function allows define_water to be added to a piped data frame. Its output is a water class, and can therefore be chained with "downstream" tidywater functions.

define_water_chain(df, output_water = "defined_water")

Arguments

  • df: a data frame containing columns with all the parameters listed in define_water
  • output_water: name of the output column storing updated parameters with the class, water. Default is "defined_water".

Returns

A data frame containing a water class column.

Details

For large datasets, using fn_once or fn_chain may take many minutes to run. These types of functions use the furrr package for the option to use parallel processing and speed things up. To initialize parallel processing, use plan(multisession) or plan(multicore) (depending on your operating system) prior to your piped code with the fn_once or fn_chain functions. Note, parallel processing is best used when your code block takes more than a minute to run, shorter run times will not benefit from parallel processing.

Examples

library(purrr) library(furrr) library(tidyr) library(dplyr) example_df <- water_df %>% define_water_chain() %>% balance_ions_once() example_df <- water_df %>% define_water_chain(output_water = "This is a column of water") %>% balance_ions_once(input_water = "This is a column of water") # Initialize parallel processing plan(multisession, workers = 2) # Remove the workers argument to use all available compute example_df <- water_df %>% define_water_chain() %>% balance_ions_once() #' #Optional: explicitly close multisession processing plan(sequential)

See Also

define_water

  • Maintainer: Sierra Johnson
  • License: Apache License (>= 2) | MIT + file LICENSE
  • Last published: 2025-01-22