mergeQ: Merge Flow into another Dataset

View source: R/mergeQ.R

mergeQR Documentation

Merge Flow into another Dataset

Description

Merges the flow (or other data) column from one or many daily-value datasets into a another dataset with one or more stations.

Usage

mergeQ(QWdata, STAID = "STAID", FLOW = "FLOW", DATES = "DATES",
  Qdata = NULL, Prefix = NULL, Plot = TRUE, ...)

Arguments

QWdata

a data frame with at least a date column on which to merge.

STAID

a character string of the name of the station-identifier column. The column name must agree in the QWdata and flow datasets.

FLOW

a character string of the name of the flow column. The column name must agree in flow datasets and will be the column name in the merged dataset. See Details

DATES

a character string of the name of the column containing the date information. The column name must agree in QWdata and flow datasets. All datasets must be sorted by date.

Qdata

a data frame containing daily-flow values.

Prefix

a character string indicating the prefix of the names of datasets containing daily-flow values.

Plot

a logical value indicating whether to plot the joint distribution of sampled flows and observed flows. See Notes for a description of the plot. Used only if a single column is specified in FLOW.

...

defines the dataset containing daily flow values for each station identifier.

Details

More than one column can be specified for FLOW when merging a single station, and the flow data are specified in Qdata.

Value

A data frame like QWdata with an attached flow column(s).

Note

The station-identifier columns must be of class character.

There are fours ways to merge flow and water-quality data:

A dataset that contains data for a single site does not require a STAID column. Qdata must be supplied. This case must be used if the flow record is incomplete or does not cover the range of dates in QWdata; all other methods will fail if that is the case. See Example 1.

A dataset that contains data for one or more sites can be merged with a dataset that contains flow data for the sites in that first dataset. This method will fail if there is not a complete list of station identifiers in the flow dataset. See Example 2.

A dataset that contains data for one or more sites can be merged with flow datasets that have names based on STAID. The structure of the name must be some common prefix followed by the station identifier. The station identifier must conform to a valid name. This method will fill in missing values (NAs) if a dataset corresponding to a station identifier is not available. See Example 3.

A dataset that contains data for one or more sites can be merged with flow datasets that have arbitrary names. Station identifiers that do not conform to valid names must be quoted. This method will fail if there is not a complete list of station identifiers supplied as arguments. See Example 4.

The plot shows the joint distribution of the sampled flows and observed flows from the sampling time period. The quantile-quantile plots are used to assess whether the sampled and observed flows have the same distribution. If the distributions are the same, then the plot will be approximately a straight line (included as a reference line). The extreme points can have more variability than points toward the center. A plot that shows the upper end trailing upward indicates that the largest flows have been under sampled and the sampled data may not give a reliable estimate of loads.

See Also

mergeNearest

Examples

## Not run: 
library(smwrData)
data(Q05078470)
data(Q05078770)
data(Qall)
data(QW05078470)
data(QWall)
#                   Example 1
#
mergeQ(QW05078470, Qdata=Q05078470, Plot=FALSE)

#                   Example 2
#
mergeQ(QWall, FLOW="Flow", Qdata=Qall, Plot=FALSE)

#                   Example 3
#
mergeQ(QWall, Prefix="Q", Plot=FALSE)

#                   Example 4
# Note quotes required for station identifiers
mergeQ(QWall, "05078470"=Q05078470, "05078770"=Q05078770, Plot=FALSE)

## End(Not run)

USGS-R/smwrBase documentation built on Oct. 18, 2022, 9:55 a.m.