# ad.plot3: Plot Results of Analytical Duplicate Analyses as Ratios In rgr: Applied Geochemistry EDA

## Description

Function to plot the results of analytical duplicate analyses as ratios vs. their means with logarithmic scaling. Classical and robust estimates for the mean/median and Relative Standard Deviations (%) are displayed. In addition to displaying this information the 95% standard error interval on the mean ratio is estimated and used to test that the mean ratio is not significantly different from one. A situation that would indicate severe systematic drift between the analytical duplicates, something that could happen if the duplicates were analysed in a separate batch at a later date, or were analysed as a group at the beginning or end of an analytical batch. The mean ratio and 95% confidence bounds for the duplicate ratios are plotted as dotted lines on the plot. If the lower detection for the analyses is defined, and it falls within the range of the duplicate meams, it will be plotted as a red vertical dotted line. To facilitate comparison between measurements, or measurements by different methods, the range of the ratio display can be defined. Optionally, the locator may be deployed so that the ratios for estimating the 95% confidence bounds on any value may be placed on the plot in a location of the user's choice. Optionally the ratio plot may be supplemented by an CPP of the ratios, in which case they are presented as side-by-side plots. For data stored in alternate forms from that expected by this function use `ad.plot4`.

## Usage

 ```1 2``` ```ad.plot3(x1, x2, xname = deparse(substitute(x1)), if.order = FALSE, ad.tol = NULL, ldl = NULL, maxrat = NULL, if.text = FALSE, if.cpp = FALSE, ...) ```

## Arguments

 `x1` a column vector from a matrix or data frame, `x1[1], ..., x1[n]`. `x2` another column vector, `x2[1], ..., x2[n]`. `x1` and `x2` must be of identical length, where `x2` is a duplicate measurement of `x1`. `xname` a title can be displayed with the plot and results, e.g., `xname = "Cu (mg/kg)"`. If this field is undefined the character string for `x` is used as a default. `if.order` by default the analytical duplicate results are plotted against their means. Alternately, setting `if.order = TRUE` causes the results to be plotted in the order in which they occur in the data file, this usually corresponds to date of analysis. `ad.tol` a tolerance level may be provided for the maximum acceptable percent ratio between duplicates when they are plotted sequentially, i.e. `if.order = TRUE`, in which case red dotted lines are added to the plot. `ldl` if the lower detection limit (ldl) of the analytical procedure is provided and falls within the range of the duplicate means it will be plotted as a vertical red dotted line. `maxrat` optionally the maximum ratio for the plot axis, the minimum is computed as `1/maxrat`, may be set. This is useful when making comparisons between elements or between measurement methods and ensures similar scaling. Otherwise `maxrat` is determined from the data. `if.text` if set `if.text = TRUE` the locator is deployed so that the ratios for estimating the 95% confidence bounds on any value may be placed on the ratio plot. `if.cpp` if set `if.cpp = TRUE` the ratio plot is displayed side-by-side with an Normal Cumulative Probability Plot (CPP) of the ratios. In this instance `if.text` is not an option. `...` any additional arguments to be passed to the `plot` function for titling, etc. For example, setting `col = 4` will result in the mean ratio and the 95% bounds on the range of the ratios beining plotted in blue.

## Details

If the data are as a single concatenated vector from a matrix or data frame as `x1[1], ..., x1[n]` followed by `x[n+1], ..., x[2n]`, or alternated as `x[1]` and `x[2]` being a pair through to `x[2*i+1]` and `x[2*i+2]` for the `i in 1:n` duplicate pairs use function `ad.plot4`.

For examples see `ad.plot4` as Geological Survey of Canada National Geochemical Reconnaissance survey data are not stored in this format. This function is present as the graphical equivalent to `anova1`.

## Note

Any less than detection limit values represented by negative values, or zeros or other numeric codes representing blanks in the data, must be removed prior to executing this function, see `ltdl.fix.df`.

## Author(s)

Robert G. Garrett

`ad.plot4`, `ad.plot2`, `ltdl.fix.df`