as.qw: Water-quality Data Conversion

as.qwR Documentation

Water-quality Data Conversion

Description

Converts data and meta data to a water-quality data (qw) object: various methods.

Usage

as.qw(values, remark.codes, value.codes, reporting.level, reporting.method,
  reporting.units, analyte.method, analyte.name, unique.code, value2)


  ## S4 method for signature 
## 'numeric,
##   character,
##   character,
##   numeric,
##   character,
##   character,
##   character,
##   character,
##   character,
##   missing'
as.qw(values,
  remark.codes, value.codes, reporting.level, reporting.method, reporting.units,
  analyte.method, analyte.name, unique.code, value2)


  ## S4 method for signature 
## 'numeric,
##   character,
##   character,
##   numeric,
##   character,
##   character,
##   character,
##   character,
##   character,
##   numeric'
as.qw(values,
  remark.codes, value.codes, reporting.level, reporting.method, reporting.units,
  analyte.method, analyte.name, unique.code, value2)

Arguments

values

the uncensored values and optionally the censored values.

remark.codes

the remarks codes: " " or "" indicated uncensored, "<" indicates left-censoring, ">" indicates right censoring. The special remark code "M" is created when the value is rounded to 0 by NWIS. In this case, the value is set to less than the reporting level if the reporting level is not the missing value NA, otherwise the value is set to missing NA and "M" is retained as the remark code. Other codes have a special meaning that can be modified by value.codes.

value.codes

special value qualifier codes. See Lorenz and others, 2014 for a description of these codes and the special remark.codes.

reporting.level

the reporting level associated with each value. Note that if the reporting level is not known, then NA_real_ should be used instead of using any arbitrary value.

reporting.method

the method used to compute the reporting level. These can be arbitrary codes, known only to the user.

reporting.units

the reporting units. A few defined units such as "mg/l" are recognized and used by the software.

analyte.method

the method used to compute the concentration. These can be arbitrary codes, known only to the user.

analyte.name

the name of the analyte. A few names are recongnized such as "chloride" and used by the software.

unique.code

an arbitrary code identifying unique instances of data. For data retreived from the US Geological Survey, this should be the 5-digit parameter code.

value2

for interval censored data, the upper value.

Details

Two methods for constructing water-quality data are defined in the current version. The first method works well for un-, left-, and right-censored data where the remark code and value can completely define the numeric values. The second method works for any censored data, including interval-censored data, where an upper and lower range of values are required. For the second method, values is the lower limit of the range and for left-censored data, may be either -Inf, NA, or 0. If -Inf, then the value is treated as strictly left-censored, otherwise, the lower limit is set to 0, which corresponds to the traditional interpretation of left-censored water-quality data. For the second method, value2 is the upper limit and for right-censored data will always be set to Inf.

Value

An object of class "qw" that contains the numeric data in a two-column matrix and the meta data as additional slot information.

Note

The class "qw" is intended to be a flexible and user-friendly way to store and manage water-quality data. The meta data that are stored with the numeric and remark data are essential for unbiased statistical analysis and for reducing other errors in interpretation or computation.

Objects of class "qw" also have a slot named "rounding" that controls how the data are roudend when printed. That slot is an integer vector of length 2, the first element is the maximum number of significant figures and the second is the maximum number of decimal places to show. The default value used by as.qw is c(2L,3L). It can be changed by specifically modifying the slot value.

References

Lorenz, D.L., in preparation

See Also

importNWISqw


USGS-R/smwrQW documentation built on Oct. 11, 2022, 6:13 a.m.