Exploring Water Quality Monitoring Data

Functions to assist in the processing and exploration of data from environmental monitoring programs. The package name stands for "water quality" and reflects the original focus on time series data for physical and chemical properties of water, as well as the biota. Intended for programs that sample approximately monthly, quarterly or annually at discrete stations, a feature of many legacy data sets. Most of the functions should be useful for analysis of similar-frequency time series regardless of the subject matter.

output: github_document

Project Status: Active – The project has reached a stable, usable state and is being actively developed. CRAN_Status_Badge


You can install wql from github with:

# install.packages("devtools")


The main purpose of wql is to explore seasonal time series through plots and nonparametric trend tests. It was created originally to examine water quality data sets (hence, wql) but is suitable as a more general purpose set of tools for looking at annual or seasonal time series.

One of the more tedious tasks in exploring environmental data sets is creating usable time series from the original complex data sets, especially when you want many series at will that group data in different ways. So wql also provides a way of transforming data sets to a common format that then allows a diversity of time series to be created quickly. A few functions are specific to the fields of limnology and oceanography.

The plots are designed for easy use, not for publication-quality graphs. Nonetheless, extensive customization is possible by passing options through ..., adding annotations in the case of base graphics, and adding layers in the case of ggplot2 objects.

Two functions are used mainly for preparing the times series:

  • a function that transforms incoming data to a common data structure in the form of the WqData class
  • a function that easily prepares time series objects from this class

The WqData class can be easily adapted to non-aquatic data. Obviously, the depth field can be used for elevation in atmospheric studies. But more generally, the site and depth fields can be used for many two-way classifications and don't need to refer to spatial location.

Some of the time series functions include:

  • a variety of plots to examine changes in seasonal patterns
  • nonparametric trend tests
  • time series interpolation and related manipulations
  • a simple decomposition of a series into different time scales
  • phenological analyses
  • the use of empirical orthogonal functions to detect multiple independent mechanisms underlying temporal change

A few functions are specialized for the aquatic sciences:

  • converting between oxygen concentrations and percent saturation
  • converting between salinity and conductivity


The capabilities of wql are more fully explained in the accompanying vignette: wql: Exploring environmental monitoring data


This package is am independent fork of the archived CRAN package wq. To date, improvements have been focused on improving the documentation and code readability.

#> To cite wq in publications use:
#>   Alan D. Jassby and James E. Cloern (). wq: Some tools for
#>   exploring water quality monitoring data. R package version
#>   0.4.9. http://cran.r-project.org/package=wq
#> A BibTeX entry for LaTeX users is
#>   @Manual{jassbywq,
#>     title = {wq: Exploring water quality monitoring data},
#>     author = {Alan D. Jassby and James E. Cloern},
#>     note = {R package version 0.4.9},
#>     url = {http://CRAN.R-project.org/package=wq},
#>   }


wql 0.4.9

  • Fork and rebrand wq to wql
  • Added roxygen documentation

wq 0.4.8

  • eof: Shift id to row name in output.
  • eofPlot: Fix for non-numeric row names in original data.
  • mannKen: Use different definition of relative sen slope.
  • pett: Add change.size. Get actual change.time for zoo objects.
  • phenoAmp: Change to more versatile output statistics. Change argument name.
  • phenoPhase: Change argument name.
  • seaKen: Use different definition of relative sen slope.
  • trendHomog: Ignore seasons with insufficient data.

wq 0.4.7

  • Add back html vignette.
  • Fix global variable notes.
  • eof: Calculation method changed.
  • eofNum: Remove ruleN-based colouring.
  • eofPlot: Remove Monte Carlo lines.
  • plotTsTile: Default to median instead of mean.
  • ruleN: Remove.

wq 0.4.6

  • decompTs: Remove startyr and endyr. Add median as default centering method.
  • mannKen: Remove "tau" argument. Use median instead of mean for relative. Add exact p-values. Allow matrix and data.frame. Change plot.
  • pett.R: Add new function with plot for Pettitt test.
  • plotTs: Remove plot.order argument. Improve legend.
  • plotTsAnom: Remove plot.order argument.
  • seaKen: Allow matrix and data.frame. Add plot.
  • seaRoll: Change arguments and plot.
  • seasonTrend: Change arguments. Remove ls trend method. Improve legend.

wq 0.4.5

  • eofPlot.R: Fix argument to geom_hline.

wq 0.4.4

  • wq-internal.R: Removed.
  • plot WqData-class: Added global variable definitions.

wq 0.4.3

  • ammFrac: Remove.
  • layOut: Remove.

wq 0.4-1

  • mannKen: Preserve station order in data matrix.
  • mannKen: Modify examples to be more useful.
  • NAMESPACE: Add importFrom("methods").
  • NAMESPACE: Remove all require(zoo) from functions.
  • plotSeason: Enable plotting by arbitrary eras.
  • plotSeason: Fixed error when num.era=1.
  • vignette: Remove unnecessary commands from preamble.
  • wqData: Require locus to be length 3.
  • WqData-class: Change tz="UTC" default in as.Date for summary.

wq 0.3-11

  • [: method now exists for WqData objects.
  • plotTsTile: has additional options and a corrected help file.
  • subset, transform: no longer used within code.
  • wqData: handles collision between locus and wq variables with same name.
  • minor bug fixes.

wq 0.3-10

  • Vignette (re-)included.
  • Minor changes in plotting functions.

wq 0.3-8

  • Updated for ggplot2 0.9.2.

wq 0.3-7

  • Minor changes to manual.

wq 0.3-6

  • Minor changes to code, with no changes in behaviour.

wq 0.3-5

  • Addresses issues introduced with version 0.9 of ggplot2.
  • Uses reshape2 instead of reshape.
  • plotTsAnom and seasonTrend: minor plotting changes.

wq 0.3-4

  • date2decyear: Converts dates to numeric years.
  • interpTs: More options for replacing NAs.
  • plotTs: Time series line plot plus isolated points
  • plotTsAnom: Now works for matrix time series.
  • theme_wq: Simplified version of theme_grey in package "ggplot2".
  • tsMake: No longer excruciatingly slow when layer = "max.depths"

wq 0.3-3

  • plotTsAnom: time series anomaly plot.
  • tsMake: Now aggregates depths (and days) by quantiles as well as means.
  • plotSeason: Fixed problem with missing data treatment.
  • tsSub: Fixed problem with incorrect starting month.

wq 0.3-1

  • plot method for class "WqData": Boxplots instead of stripcharts. Also fixed behaviour when less than 10 unique variables.
  • plotSeason: Changed "by.month" option to standardized anomalies.
  • tsMake: Added option to create series for "bottom" of water column.
  • Version requirement is R 10.0.
  • Vignette file size fixed so it can be downloaded from HTML help.

wq 0.3

  • All plot functions now produce objects of class "ggplot".
  • layOut: Lays out graphs of class ggplot.
  • mannKen: Added mts and plot options.
  • meanSub: Utility function to average subsets.
  • mts2ts: Prepare spatial time series for further analysis.
  • plotSeason: Added another way of plotting.
  • seaRoll: Plotting is an additional option.
  • trendHomog: Test for homogeneity of seasonal trends.
  • tsSub: Utility function to drop seasons in a ts.
  • plotEof: Changed to eofPlot.

wq 0.2-9

  • phenoPhase: Integration defaults can now be changed, if necessary.
  • plotSeason: Added smoother when type='by.month'.
  • seasonTrend: Changed appearance and some options.
  • plotSeason: Fixed problem when type='by.month'.
  • plotTsTile: Now plots correct colours when four=FALSE.
  • tsMake: Fixed problem when layer of class "numeric".

wq 0.2-8

  • wqData: Changed "narrow" to "long".
  • plotSeas: Changed to plotSeason.
  • ammFrac: New function for un-ionized ammonium.
  • plotSeason: Added option to plot individual months for entire record.
  • seasonTrend: New function for time series trends by season.
  • tsMake: Now allows for more ways of specifying depths.
  • mannKen, seaKen: Now gives correct sign when trend given as %.
  • phenoAmp: Fixed problem when subsetting months leaves no data for year.
  • phenoPhase: Fixed problem when subsetting months and x is a "zoo" object.
  • plotSeason: Now handles num = 1.
  • tsMake: Fixed problem when focus consisted of a single variable or site.

wq 0.2-5

  • interpTs: Option to fill with long-term mean or median.
  • plotSeas: Option to choose number of intervals.
  • WqData plot method: Option to choose variables.
  • phenoPhase: Fixed problem where max.time month number given relative to subset rather than whole year
  • plotTsTile: More useful error message when not enough data.
  • seaRoll: Fixed problem with frequencies other than 12.
  • tsMake: Remove need to specify layer if no depth info.
  • WqData subset method: Removed because of strategy that WqData objects should not be changed.
  • wqData: Argument value "narrow" changed to more conventional "long".
  • wqData: Now requires time.format to be specified.
  • wqData: Now ensures variable is a factor when type = "long".

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.4.9 by Joseph Stachelek, 3 years ago


Report a bug at https://github.com/jsta/wql/issues

Browse source code at https://github.com/cran/wql

Authors: Alan Jassby [aut] , James Cloern [ctb] , Joseph Stachelek [ctb, cre]

Documentation:   PDF Manual  

Task views: Hydrological Data and Modeling

GPL-2 license

Imports graphics, grDevices, methods, stats, ggplot2, reshape2, zoo

Suggests knitr, rmarkdown

See at CRAN