Learn R Programming

mbgraphic (version 1.0.1)

varclust: Clustering of numeric variables

Description

The function clusters variables using the average linkage algorithm.

Usage

varclust(data, c = NULL, mincor = NULL)

Arguments

data

A data frame.

c

A positive integer. The number of clusters.

mincor

Numeric. The minimal correlation within each of the single clusters.

Value

A list with the following object:

c

The number of clusters.

mincor

The minimal correlation within each of the single clusters.

clusters

The cluster allocation for each variable.

clusrep

A character vector indicating the variables which are used as representatives for the clusters.

dfclusrep

A data frame which only holds the cluster representatives as variables.

Details

The number of clusters can be set by specifying c or choosing mincor (but not both at the same time). If mincor is used, the number of clusters is defined by a minimum correlation. That means every single pair of variables in the individual clusters is correlated with a value which is at least mincor.

Examples

Run this code
# NOT RUN {
data(Election2005)
# }
# NOT RUN {
# Variable clustering based on minimum correlation
vc1 <- varclust(Election2005,mincor=0.8)
vc1$c # The number of clusters is 45

# Variable clustering based on the number of clusters
vc2 <- varclust(Election2005,30)
vc2$mincor # The minimum correlation is 0.63
# }

Run the code above in your browser using DataLab