calc_wqi | R Documentation |
Calculates a water quality index for a series of variables, values with upper limits and optionally lower limits using the method detailed in the CCME Water Quality Index 1.0 User's Manual.
calc_wqi(x, by = NULL, messages = getOption("wqbc.messages", default = TRUE))
x |
A data.frame to calculate the WQI for. |
by |
An optional character vector of the columns in x to calculate the WQI by. |
messages |
A flag indicating whether to print messages. |
The upper limits can be generated using the wqbc::calc_limits()
function
or can be provided by the user. If values are zero and detection limits are provided
then the values are set to be the detection limits. This is important when
the variable has lower limits because otherwise the excursion will be infinity
and it will not be possible to calculate the WQI. In this case calc_wqi
throws an informative error. Finally it is important to note that in order
for the WQI to be calculated the data set must include four variables each
with non-missing values on at least four separate days. In addition
to calculating the WQI the function also generates
95% Lower and Upper bootstrap confidence intervals about the WQI. The confidence
intervals are generated by first spreading the data into wide format where each
row represents one date and then resampling the rows with replacement to
generate 1,000 replicates. The confidence intervals are the 2.5% and 97.5%
percentiles of the replicate WQIs.
wqbc::calc_limits()
data(ccme)
calc_wqi(ccme, messages = TRUE)
calc_wqi(ccme, by = "Date", messages = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.