The output of the kmeans clustering function produces a vector of cluster membership. The score.items and cluster.cor functions require a matrix of keys. cluster2keys does this.

May also be used to take the output of an ICLUST analysis and find a keys matrix. (By doing a call to the factor2cluster function.

cluster2keys(c)

Arguments

c

A vector of cluster assignments or an object of class “kmeans" that contains a vector of clusters.

Details

Note that because kmeans will not reverse score items, the clusters defined by kmeans will not necessarily match those of ICLUST with the same number of clusters extracted.

Value

keys

A matrix of keys suitable for score.items or cluster.cor

Author

William Revelle

Examples

test.data <- Harman74.cor$cov
kc <- kmeans(test.data,4)
keys <- cluster2keys(kc)
keys  #these match those found by ICLUST
#>       [,1] [,2] [,3] [,4]
#>  [1,]    1    0    0    0
#>  [2,]    1    0    0    0
#>  [3,]    1    0    0    0
#>  [4,]    1    0    0    0
#>  [5,]    0    0    0    1
#>  [6,]    0    0    0    1
#>  [7,]    0    0    0    1
#>  [8,]    0    0    0    1
#>  [9,]    0    0    0    1
#> [10,]    0    0    1    0
#> [11,]    0    0    1    0
#> [12,]    0    0    1    0
#> [13,]    0    1    0    0
#> [14,]    0    0    1    0
#> [15,]    0    0    1    0
#> [16,]    1    0    0    0
#> [17,]    0    0    1    0
#> [18,]    0    0    1    0
#> [19,]    0    0    1    0
#> [20,]    0    1    0    0
#> [21,]    0    1    0    0
#> [22,]    0    1    0    0
#> [23,]    0    1    0    0
#> [24,]    0    1    0    0
cluster.cor(keys,test.data)
#> Call: cluster.cor(keys = keys, r.mat = test.data)
#> 
#> (Standardized) Alpha:
#> [1] 0.71 0.80 0.77 0.90
#> 
#> (Standardized) G6*:
#> [1] 0.75 0.83 0.82 0.90
#> 
#> Average item correlation:
#> [1] 0.33 0.40 0.30 0.64
#> 
#> Number of items:
#> [1] 5 6 8 5
#> 
#> Signal to Noise ratio based upon average r and n 
#> [1] 2.5 4.0 3.4 8.8
#> 
#> Scale intercorrelations corrected for attenuation 
#>  raw correlations below the diagonal, alpha on the diagonal 
#>  corrected correlations above the diagonal:
#>      [,1] [,2] [,3] [,4]
#> [1,] 0.71 0.87 0.58 0.59
#> [2,] 0.66 0.80 0.85 0.78
#> [3,] 0.43 0.67 0.77 0.54
#> [4,] 0.47 0.66 0.45 0.90