Learn R Programming

tidywater (version 0.7.0)

biofilter_toc_once: Apply `biofilter_toc` function and output a data frame

Description

This function allows biofilter_toc to be added to a piped data frame. Its output is a data frame with updated TOC, DOC, and BDOC

Usage

biofilter_toc_once(
  df,
  input_water = "defined_water",
  ebct = 0,
  ozonated = TRUE
)

Value

A data frame with updated DOC, TOC, and BDOC concentrations.

Arguments

df

a data frame containing a water class column, which has already been computed using define_water_chain. The df may include a column indicating the EBCT or whether the water is ozonated.

input_water

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

ebct

The empty bed contact time (min) used for the biofilter

ozonated

Logical; TRUE if the water is ozonated (default), FALSE otherwise

Details

The data input comes from a `water` class column, as initialized in define_water_chain.

If the input data frame has column(s) named "ebct" or "ozonated", the function uses those as arguments. Note: The function can use either a column or the direct function arguments, not both.

tidywater functions cannot be added after this function because they require a `water` class input.

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.

See Also

biofilter_toc

Examples

Run this code

library(purrr)
library(furrr)
library(tidyr)
library(dplyr)

example_df <- water_df %>%
  define_water_chain() %>%
  biofilter_toc_once(input_water = "defined_water", ebct = 10, ozonated = FALSE)

example_df <- water_df %>%
  define_water_chain() %>%
  mutate(
    ebct = rep(c(10, 15, 20), 4),
    ozonated = c(rep(TRUE, 6), rep(FALSE, 6))
  ) %>%
  biofilter_toc_once(input_water = "defined_water")

# Initialize parallel processing
plan(multisession, workers = 2) # Remove the workers argument to use all available compute
example_df <- water_df %>%
  define_water_chain() %>%
  biofilter_toc_once(input_water = "defined_water", ebct = c(10, 20))

# Optional: explicitly close multisession processing
plan(sequential)

Run the code above in your browser using DataLab