Learn R Programming

SPARTAAS (version 1.2.4)

CAdist: Distance matrix based on correspondence analysis results

Description

Perform a correspondence analysis on a contingency table and then return the distance matrix of the coordinates (you can choose the number of axes to use to build the distance matrix with the nCP parameter).

Usage

CAdist(df, nPC = NULL, graph = TRUE)

Value

D

The distance matrix

Arguments

df

Data.frame, matrix or table with the data for the correspondence analysis.

nPC

Number of principal components to be retained for the construction of the distance matrix. Must be between 1 and the minimum of ncol - 1 and nrow - 1. Could also be "max".

graph

Logical parameter for plotting the Correspondence Analysis (Axis1, Axis2).

Author

A. COULON

L. BELLANGER

P. HUSI

Examples

Run this code
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.
library(SPARTAAS)
data(datangkor)

## contingency table
cont <- datangkor$contingency

distance <- CAdist(cont, nPC = "max")
distance

## run without printing the plot
distance <- CAdist(cont, nPC = "max", graph=FALSE)

Run the code above in your browser using DataLab