Learn R Programming

rgr (version 1.1.15)

alts2dups: Create a Matrix of Duplicate Pairs from Sequential Data

Description

Function to take data stored as stacked records or alternating rows of records for ndup duplicate pairs and generate a matrix with ndup rows and two columns for the duplicate data, for further details see x in Arguments below. The function returns a matrix for processing.

Usage

alts2dups(x, ifalt = FALSE)

Arguments

x

a column vector from a matrix or data frame, x[1], ..., x[2*n]. The default is that the first n members of the vector are the first measurements and the second n members are the duplicate measurements. If the measurements alternate, i.e. duplicate pair 1 measurement 1 followed by measurement 2, etc., set ifalt = TRUE.

ifalt

set ifalt = TRUE to accommodate alternating sets of paired observations.

Value

xx

a ndup by 2 matrix containing the duplicate pairs. Row names are sequenced 1:ndup and the two column names are generated from the input variable name, x with .1 or .2 appended, respectively.

Details

Function provides an easy procedure with function plot to present duplicate data as an x-y plot. The matrix generated can be passed directly to plot in its call and the matrix column headings synthesized from the input variable name are used as plot axis titles.

Examples

Run this code
# NOT RUN {
## Make test data available
data(ad.test)
attach(ad.test)

## Save matrix of duplicate pairs
test.save <- alts2dups(Cu, ifalt = TRUE)

## Plot analytical duplicate analyses
plot(alts2dups(Cu, ifalt = TRUE), log = "xy")

## Clean-up and detach test data
rm(test.save)
detach(ad.test)
# }

Run the code above in your browser using DataLab