Learn R Programming

tidywater (version 0.7.0)

define_water_once: Apply `define_water` and output a dataframe

Description

This function allows define_water to be added to a piped data frame. It outputs all carbonate calculations and other parameters in a data frame. tidywater functions cannot be added after this function because they require a `water` class input.

Usage

define_water_once(df)

Value

A data frame containing columns that were filled or calculated based on define_water.

Arguments

df

a data frame containing columns with all the parameters listed in define_water

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.

See Also

define_water

Examples

Run this code
library(purrr)
library(furrr)
library(tidyr)
library(dplyr)

example_df <- water_df %>% define_water_once()

# Initialize parallel processing
plan(multisession, workers = 2) # Remove the workers argument to use all available compute
example_df <- water_df %>% define_water_once()

# Optional: explicitly close multisession processing
plan(sequential)

Run the code above in your browser using DataLab