Learn R Programming

rgr (version 1.1.0)

gx.md.print: Function to Display Membership Probabilities

Description

Function to display the Mahalanobis distances (MDs) and predicted probabilities of membership (ppm), together with other relevant data, following computations by functions gx.md.gait, gx.mva or gx.robmva. The user may select the predicted probability of membership below which the results are displayed. Optionally the entire generated table may be saved as a csv file for future use.

Usage

gx.md.print(xx, pcut = 0.1, file = NULL)

Arguments

xx
the data to be displayed in a cbind construct, see Details below.
pcut
the probabilitity of group membership below which records will be displayed on the current device in ascending order of membership probability, i.e. most outlying individuals first.
file
the file name for saving the function output in the R working directory, see Details below.

Value

  • The displayed table, table.rows, is returned and may be saved as an object if required. It will contain the information passed to the function as xx sorted by MD and with appropriate column headings.

Details

The dataframe from which the matrices were derived from for use by the above listed functions must be attached if such items as sample IDs, coordinates and data values are to be displayed. Those items and/or variables to be displayed must be appended in a cbind construct following the MDs and ppms extracted from the saved objects from the above listed functions. For example, cbind(save.sind$MD, save.sind$ppm, ID, Zn, Cu, Cd, Fe, Mn). The table generated by the function may be saved as a csv file in the working directory, for example, file = tablename.csv.

See Also

gx.md.gait, gx.mva, gx.robmva, gx.mvalloc, gx.mvalloc.print.

Examples

Run this code
## Make test data available
data(sind)
attach(sind)
sind.mat <- as.matrix(sind[, -c(1:3)])
## Ensure all data are in the same units (mg/kg)
sind.mat2open <- sind.mat
sind.mat2open[, 2] <- sind.mat2open[, 2] * 10000

## Estimate and display robust Mahalanobis distances
sind.save <- gx.md.gait(ilr(sind.mat2open), mcdstart = TRUE, ifadd = NULL)
gx.md.print(cbind(sind.save$md, sind.save$ppm, ID, Zn, Cu, Cd, Fe, Mn),
pcut = 0.3)

## Save display for future use
gx.md.print(cbind(sind.save$md, sind.save$ppm, ID, Zn, Cu, Cd, Fe, Mn),
file = "sind.save.ilr.mds.csv")

## Clean-up and detach test data
rm(sind.mat)
rm(sind.mat2open)
rm(sind.save)
detach(sind)

Run the code above in your browser using DataLab