Learn R Programming

amap (version 0.8-20)

diss: Compute a dissimilarity matrix

Description

Compute a dissimilarity matrix from a data set (containing only factors).

Usage

diss(x, w=rep(1,ncol(x)) )

Value

A dissimilarity matrix.

Arguments

x

A matrix or data frame containing only factors.

w

A vector of weight, by default each variable has got same weight

Author

Antoine Lucas

Details

Case of N individuals described by P categorical variables: each element (i,j) of the signed similarities array is computed by sommation over the P variables of the contributions of each variable, multiplied by the weight of the variable. The contribution of a given categorical variable is +1 if the individual i and j are in the same class, and is -1 if they are not.

See Also

Dist, pop

Examples

Run this code
data <-
matrix(c(1,1,1,1,1
        ,1,2,1,2,1
        ,2,3,2,3,2
        ,2,4,3,3,2
        ,1,2,4,2,1
        ,2,3,2,3,1),ncol=5,byrow=TRUE)

diss(data)

## With weights
diss(data,w=c(1,1,2,2,3))

Run the code above in your browser using DataLab