Learn R Programming

rgr (version 1.1.7)

gx.md.display: Function to Display Membership Probabilities and Other Relevant Data

Description

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

Usage

gx.md.display(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 data frame 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, with the .csv being appended in the function. See example below. If file = "" or file = "" a default file name is generated as MDs_&_variables.csv.

See Also

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

Examples

Run this code
## Make test data available
data(sind.mat2open)
data(sind)
attach(sind)
## data frame sind attached to provide access to row IDs

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

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

## Clean-up
rm(sind.save)
detach(sind)

Run the code above in your browser using DataLab