In order to use the beale function and supporting classes, a dataframe must be prepared with the following fields:
1) *date* the sample date, encoded as an R `Date` type, 2) *discharge* the daily mean discharge, provided in cubic meters per second, and 3) *concentration* the concentration corresponding to the daily discharge, in milligrams per liter (NA if no sample taken that day).
library(autobeale) library(dplyr)
The autobeale::beale
function expects the incoming data to be provided in pairwise fashion. There should be a discharge value provided for every day within the timeframe for the laoding calculation, with a concentration value provided on days that were sampled. dplyr::left_join
can be used to quickly create an input dataset suitable for use with the beale
function.
discharge_file <- system.file( "extdata", "ROCKFLOW.DAT", package="autobeale") concentration_file <- system.file( "extdata", "ROCKNO23.DAT", package="autobeale") discharge_data <- read.table( discharge_file, header=TRUE ) concentration_data <- read.table( concentration_file, header=TRUE ) discharge_conc_df <- NULL discharge_conc_df <- dplyr::left_join(discharge_data, concentration_data, by=c("date" = "date") ) # don't forget to convert the discharge value to cubic meters per second! discharge_conc_df$discharge <- cfs_to_cms( discharge_conc_df$discharge )
The resulting dataframe looks like this:
knitr::kable(head(discharge_conc_df, 10))
Once the dataset is in good shape, we can call beale
to calculate the load. Note that the beale
function expects discharge to be provided in units of cubic meters per second, with concentration data provided in units of milligrams per liter.
result_list <- beale( discharge_cms=discharge_conc_df$discharge, concentration_mg_L=discharge_conc_df$concentration ) print( result_list, digits=2 )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.