File: clusplot-out.Rout.save

package info (click to toggle)
cluster 2.1.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,728 kB
  • sloc: ansic: 3,397; sh: 20; makefile: 2
file content (123 lines) | stat: -rw-r--r-- 3,229 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123

R version 3.5.0 alpha (2018-03-28 r74481)
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(cluster)
> 
> ### clusplot() & pam() RESULT checking ...
> 
> ## plotting votes.diss(dissimilarity) in a bivariate plot and
> ## partitioning into 2 clusters
> data(votes.repub)
> votes.diss <- daisy(votes.repub)
> for(k in 2:4) {
+     votes.clus <- pam(votes.diss, k, diss = TRUE)$clustering
+     print(clusplot(votes.diss, votes.clus, diss = TRUE, shade = TRUE))
+ }
$Distances
         [,1]     [,2]
[1,]   0.0000 154.8601
[2,] 154.8601   0.0000

$Shading
[1] 22.12103 20.87897

$Distances
         [,1] [,2]     [,3]
[1,]   0.0000   NA 140.8008
[2,]       NA    0       NA
[3,] 140.8008   NA   0.0000

$Shading
[1] 25.602967  5.292663 15.104370

$Distances
         [,1] [,2]     [,3]     [,4]
[1,]   0.0000   NA 117.2287 280.7259
[2,]       NA    0       NA       NA
[3,] 117.2287   NA   0.0000       NA
[4,] 280.7259   NA       NA   0.0000

$Shading
[1] 15.431339  3.980743 10.145454 19.442464

> 
> ## plotting iris (dataframe) in a 2-dimensional plot and partitioning
> ## into 3 clusters.
> data(iris)
> iris.x <- iris[, 1:4]
> 
> for(k in 2:5)
+     print(clusplot(iris.x, pam(iris.x, k)$clustering, diss = FALSE))
$Distances
          [,1]      [,2]
[1,] 0.0000000 0.5452161
[2,] 0.5452161 0.0000000

$Shading
[1] 18.93861 24.06139

$Distances
         [,1]     [,2]     [,3]
[1,] 0.000000 1.433071 2.851715
[2,] 1.433071 0.000000       NA
[3,] 2.851715       NA 0.000000

$Shading
[1] 18.987588 17.166940  9.845472

$Distances
         [,1]    [,2]      [,3]      [,4]
[1,] 0.000000 2.24157 1.6340329 3.0945887
[2,] 2.241570 0.00000        NA        NA
[3,] 1.634033      NA 0.0000000 0.9461858
[4,] 3.094589      NA 0.9461858 0.0000000

$Shading
[1] 12.881766 14.912379 13.652381  7.553474

$Distances
         [,1]      [,2]     [,3]       [,4]       [,5]
[1,] 0.000000 1.9899160 1.552387 3.11516148 3.96536391
[2,] 1.989916 0.0000000       NA         NA 0.94713417
[3,] 1.552387        NA 0.000000 1.17348334 2.22769309
[4,] 3.115161        NA 1.173483 0.00000000 0.04539385
[5,] 3.965364 0.9471342 2.227693 0.04539385 0.00000000

$Shading
[1] 10.369738 11.560147 10.088431 14.857590  5.124093

> 
> 
> .Random.seed <- c(0L,rep(7654L,3))
> ## generate 25 objects, divided into 2 clusters.
> x <- rbind(cbind(rnorm(10,0,0.5), rnorm(10,0,0.5)),
+            cbind(rnorm(15,5,0.5), rnorm(15,5,0.5)))
> print.default(clusplot(px2 <- pam(x, 2)))
$Distances
         [,1]     [,2]
[1,] 0.000000 5.516876
[2,] 5.516876 0.000000

$Shading
[1] 20.18314 22.81686

> 
> clusplot(px2, labels = 2, col.p = 1 + px2$clustering)
> 
> proc.time()
   user  system elapsed 
  0.320   0.070   0.449