File: daisy-ex.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 (926 lines) | stat: -rw-r--r-- 42,843 bytes parent folder | download | duplicates (2)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926

R version 4.2.0 Patched (2022-05-13 r82353) -- "Vigorous Calisthenics"
Copyright (C) 2022 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.

> ## For different cluster versions
>
> require(cluster)
Loading required package: cluster
> 
> if(interactive()) print(packageDescription("cluster"))
> 
> ## trivial cases should 'work':
> daisy(cbind(1))
Dissimilarities :
dissimilarity(0)

Metric :  euclidean 
Number of objects : 1
> (d10 <- daisy(matrix(0., 1,0))); str(d10)
Dissimilarities :
dissimilarity(0)

Metric :  euclidean 
Number of objects : 1
 'dissimilarity' num(0) 
 - attr(*, "Size")= int 1
 - attr(*, "Metric")= chr "euclidean"
> d01 <- daisy(matrix(0., 0,1))
> if(paste(R.version$major, R.version$minor, sep=".") >= "2.1.0")
+     print(d01)
Dissimilarities :
dissimilarity(0)

Metric :  euclidean 
Number of objects : 0
> str(d01)
 'dissimilarity' num(0) 
 - attr(*, "Size")= int 0
 - attr(*, "Metric")= chr "euclidean"
> d32 <- data.frame(eins=c("A"=1,"B"=1,"C"=1), zwei=c(2,2,2))
> daisy(d32)
Dissimilarities :
  A B
B 0  
C 0 0

Metric :  euclidean 
Number of objects : 3
> daisy(d32, stand = TRUE)
Dissimilarities :
  A B
B 0  
C 0 0

Metric :  euclidean 
Number of objects : 3
Warning message:
In daisy(d32, stand = TRUE) :
  'x' has constant columns 1, 2; these are standardized to 0
> daisy(d32, type = list(ordratio="zwei"))
Dissimilarities :
  A B
B 0  
C 0 0

Metric :  mixed ;  Types = I, T 
Number of objects : 3
> 
> 
> str(d5 <- data.frame(a= c(0, 0, 0,1,0,0, 0,0,1, 0,NA),
+                      b= c(NA,0, 1,1,0,1, 0,1,0, 1,0),
+                      c= c(0, 1, 1,0,1,NA,1,0,1, 0,NA),
+                      d= c(1, 1, 0,1,0,0, 0,0,0, 1,0),
+                      e= c(1, NA,0,1,0,0, 0,0,NA,1,1)))
'data.frame':	11 obs. of  5 variables:
 $ a: num  0 0 0 1 0 0 0 0 1 0 ...
 $ b: num  NA 0 1 1 0 1 0 1 0 1 ...
 $ c: num  0 1 1 0 1 NA 1 0 1 0 ...
 $ d: num  1 1 0 1 0 0 0 0 0 1 ...
 $ e: num  1 NA 0 1 0 0 0 0 NA 1 ...
> (d0 <- daisy(d5))
Dissimilarities :
          1        2        3        4        5        6        7        8
2  1.290994                                                               
3  1.936492 1.581139                                                      
4  1.118034 1.936492 2.000000                                             
5  1.936492 1.118034 1.000000 2.236068                                    
6  1.825742 1.825742 0.000000 1.936492 1.118034                           
7  1.936492 1.118034 1.000000 2.236068 0.000000 1.118034                  
8  1.581139 1.936492 1.000000 1.732051 1.414214 0.000000 1.414214         
9  2.236068 1.581139 1.581139 1.936492 1.118034 1.825742 1.118034 1.936492
10 0.000000 1.581139 1.732051 1.000000 2.000000 1.581139 2.000000 1.414214
11 1.581139 1.581139 1.825742 1.825742 1.290994 1.825742 1.290994 1.825742
          9       10
2                   
3                   
4                   
5                   
6                   
7                   
8                   
9                   
10 2.236068         
11 0.000000 1.825742

Metric :  euclidean 
Number of objects : 11
Warning message:
In daisy(d5) : binary variable(s) 1, 2, 3, 4, 5 treated as interval scaled
> (d1 <- daisy(d5, type = list(asymm = 1:5)))
Dissimilarities :
           1         2         3         4         5         6         7
2  0.5000000                                                            
3  1.0000000 0.6666667                                                  
4  0.3333333 0.7500000 0.8000000                                        
5  1.0000000 0.5000000 0.5000000 1.0000000                              
6  1.0000000 1.0000000 0.0000000 0.7500000 1.0000000                    
7  1.0000000 0.5000000 0.5000000 1.0000000 0.0000000 1.0000000          
8  1.0000000 1.0000000 0.5000000 0.7500000 1.0000000 0.0000000 1.0000000
9  1.0000000 0.6666667 0.6666667 0.7500000 0.5000000 1.0000000 0.5000000
10 0.0000000 0.6666667 0.7500000 0.2500000 1.0000000 0.6666667 1.0000000
11 0.5000000 1.0000000 1.0000000 0.6666667 1.0000000 1.0000000 1.0000000
           8         9        10
2                               
3                               
4                               
5                               
6                               
7                               
8                               
9  1.0000000                    
10 0.6666667 1.0000000          
11 1.0000000        NA 0.6666667

Metric :  mixed ;  Types = A, A, A, A, A 
Number of objects : 11
> (d2 <- daisy(d5, type = list(symm = 1:2, asymm= 3:5)))
Dissimilarities :
           1         2         3         4         5         6         7
2  0.3333333                                                            
3  0.7500000 0.5000000                                                  
4  0.3333333 0.7500000 0.8000000                                        
5  0.7500000 0.2500000 0.3333333 1.0000000                              
6  0.6666667 0.6666667 0.0000000 0.7500000 0.5000000                    
7  0.7500000 0.2500000 0.3333333 1.0000000 0.0000000 0.5000000          
8  0.6666667 0.7500000 0.3333333 0.7500000 0.6666667 0.0000000 0.6666667
9  1.0000000 0.5000000 0.6666667 0.7500000 0.3333333 1.0000000 0.3333333
10 0.0000000 0.5000000 0.6000000 0.2500000 0.8000000 0.5000000 0.8000000
11 0.5000000 0.5000000 1.0000000 0.6666667 0.5000000 1.0000000 0.5000000
           8         9        10
2                               
3                               
4                               
5                               
6                               
7                               
8                               
9  1.0000000                    
10 0.5000000 1.0000000          
11 1.0000000 0.0000000 0.6666667

Metric :  mixed ;  Types = S, S, A, A, A 
Number of objects : 11
> (d2.<- daisy(d5, type = list(     asymm= 3:5)))
Dissimilarities :
           1         2         3         4         5         6         7
2  0.3333333                                                            
3  0.7500000 0.5000000                                                  
4  0.3333333 0.7500000 0.8000000                                        
5  0.7500000 0.2500000 0.3333333 1.0000000                              
6  0.6666667 0.6666667 0.0000000 0.7500000 0.5000000                    
7  0.7500000 0.2500000 0.3333333 1.0000000 0.0000000 0.5000000          
8  0.6666667 0.7500000 0.3333333 0.7500000 0.6666667 0.0000000 0.6666667
9  1.0000000 0.5000000 0.6666667 0.7500000 0.3333333 1.0000000 0.3333333
10 0.0000000 0.5000000 0.6000000 0.2500000 0.8000000 0.5000000 0.8000000
11 0.5000000 0.5000000 1.0000000 0.6666667 0.5000000 1.0000000 0.5000000
           8         9        10
2                               
3                               
4                               
5                               
6                               
7                               
8                               
9  1.0000000                    
10 0.5000000 1.0000000          
11 1.0000000 0.0000000 0.6666667

Metric :  mixed ;  Types = I, I, A, A, A 
Number of objects : 11
Warning message:
In daisy(d5, type = list(asymm = 3:5)) :
  binary variable(s) 1, 2 treated as interval scaled
> stopifnot(identical(c(d2), c(d2.)))
> (dS <- daisy(d5, stand = TRUE))# gave error in some versions
Dissimilarities :
          1        2        3        4        5        6        7        8
2  2.614264                                                               
3  4.010913 3.291786                                                      
4  3.493856 4.725761 4.757684                                             
5  4.010913 2.415752 2.000000 5.160965                                    
6  3.823025 3.801028 0.000000 4.813384 2.236068                           
7  4.010913 2.415752 2.000000 5.160965 0.000000 2.236068                  
8  3.310837 3.995202 2.025000 4.305222 2.846160 0.000000 2.846160         
9  5.558018 4.247692 4.148136 3.995202 3.493856 4.789855 3.493856 4.725761
10 0.000000 3.182103 3.587469 3.125000 4.107303 3.310837 4.107303 2.961302
11 3.416389 3.416389 3.674376 3.801028 2.614264 3.674376 2.614264 3.674376
          9       10
2                   
3                   
4                   
5                   
6                   
7                   
8                   
9                   
10 5.307417         
11 0.000000 3.801028

Metric :  euclidean 
Number of objects : 11
Warning message:
In daisy(d5, stand = TRUE) :
  binary variable(s) 1, 2, 3, 4, 5 treated as interval scaled
> stopifnot(all.equal(as.vector(summary(c(dS), digits=9)),
+                     c(0, 2.6142638, 3.4938562, 3.2933687, 4.0591077, 5.5580177),
+                     tol = 1e-7))# 7.88e-9
> 
> d5[,4] <- 1 # binary with only one instead of two values
> (d0 <- daisy(d5))
Dissimilarities :
          1        2        3        4        5        6        7        8
2  1.290994                                                               
3  1.581139 1.118034                                                      
4  1.118034 1.936492 1.732051                                             
5  1.581139 0.000000 1.000000 2.000000                                    
6  1.290994 1.290994 0.000000 1.581139 1.118034                           
7  1.581139 0.000000 1.000000 2.000000 0.000000 1.118034                  
8  1.118034 1.581139 1.000000 1.414214 1.414214 0.000000 1.414214         
9  1.825742 1.118034 1.581139 1.581139 1.118034 1.825742 1.118034 1.936492
10 0.000000 1.581139 1.414214 1.000000 1.732051 1.118034 1.732051 1.000000
11 0.000000 0.000000 1.825742 1.290994 1.290994 1.825742 1.290994 1.825742
          9       10
2                   
3                   
4                   
5                   
6                   
7                   
8                   
9                   
10 1.936492         
11 0.000000 1.290994

Metric :  euclidean 
Number of objects : 11
Warning message:
In daisy(d5) : binary variable(s) 1, 2, 3, 5 treated as interval scaled
> (d1 <- daisy(d5, type = list(asymm = 1:5)))# 2 NAs
Dissimilarities :
           1         2         3         4         5         6         7
2  1.0000000                                                            
3  1.0000000 0.5000000                                                  
4  0.5000000 1.0000000 0.7500000                                        
5  1.0000000 0.0000000 0.5000000 1.0000000                              
6  1.0000000 1.0000000 0.0000000 0.6666667 1.0000000                    
7  1.0000000 0.0000000 0.5000000 1.0000000 0.0000000 1.0000000          
8  1.0000000 1.0000000 0.5000000 0.6666667 1.0000000 0.0000000 1.0000000
9  1.0000000 0.5000000 0.6666667 0.6666667 0.5000000 1.0000000 0.5000000
10 0.0000000 1.0000000 0.6666667 0.3333333 1.0000000 0.5000000 1.0000000
11 0.0000000        NA 1.0000000 0.5000000 1.0000000 1.0000000 1.0000000
           8         9        10
2                               
3                               
4                               
5                               
6                               
7                               
8                               
9  1.0000000                    
10 0.5000000 1.0000000          
11 1.0000000        NA 0.5000000

Metric :  mixed ;  Types = A, A, A, A, A 
Number of objects : 11
Warning message:
In daisy(d5, type = list(asymm = 1:5)) :
  at least one binary variable has not 2 different levels.
> (d2 <- daisy(d5, type = list(symm = 1:2, asymm= 3:5)))
Dissimilarities :
           1         2         3         4         5         6         7
2  0.5000000                                                            
3  0.6666667 0.3333333                                                  
4  0.5000000 1.0000000 0.7500000                                        
5  0.6666667 0.0000000 0.3333333 1.0000000                              
6  0.5000000 0.5000000 0.0000000 0.6666667 0.5000000                    
7  0.6666667 0.0000000 0.3333333 1.0000000 0.0000000 0.5000000          
8  0.5000000 0.6666667 0.3333333 0.6666667 0.6666667 0.0000000 0.6666667
9  1.0000000 0.3333333 0.6666667 0.6666667 0.3333333 1.0000000 0.3333333
10 0.0000000 0.6666667 0.5000000 0.3333333 0.7500000 0.3333333 0.7500000
11 0.0000000 0.0000000 1.0000000 0.5000000 0.5000000 1.0000000 0.5000000
           8         9        10
2                               
3                               
4                               
5                               
6                               
7                               
8                               
9  1.0000000                    
10 0.3333333 1.0000000          
11 1.0000000 0.0000000 0.5000000

Metric :  mixed ;  Types = S, S, A, A, A 
Number of objects : 11
Warning message:
In daisy(d5, type = list(symm = 1:2, asymm = 3:5)) :
  at least one binary variable has not 2 different levels.
> (d2.<- daisy(d5, type = list(     asymm= 3:5)))
Dissimilarities :
           1         2         3         4         5         6         7
2  0.5000000                                                            
3  0.6666667 0.3333333                                                  
4  0.5000000 1.0000000 0.7500000                                        
5  0.6666667 0.0000000 0.3333333 1.0000000                              
6  0.5000000 0.5000000 0.0000000 0.6666667 0.5000000                    
7  0.6666667 0.0000000 0.3333333 1.0000000 0.0000000 0.5000000          
8  0.5000000 0.6666667 0.3333333 0.6666667 0.6666667 0.0000000 0.6666667
9  1.0000000 0.3333333 0.6666667 0.6666667 0.3333333 1.0000000 0.3333333
10 0.0000000 0.6666667 0.5000000 0.3333333 0.7500000 0.3333333 0.7500000
11 0.0000000 0.0000000 1.0000000 0.5000000 0.5000000 1.0000000 0.5000000
           8         9        10
2                               
3                               
4                               
5                               
6                               
7                               
8                               
9  1.0000000                    
10 0.3333333 1.0000000          
11 1.0000000 0.0000000 0.5000000

Metric :  mixed ;  Types = I, I, A, A, A 
Number of objects : 11
Warning messages:
1: In daisy(d5, type = list(asymm = 3:5)) :
  at least one binary variable has not 2 different levels.
2: In daisy(d5, type = list(asymm = 3:5)) :
  binary variable(s) 1, 2 treated as interval scaled
> ## better leave away the constant variable: it has no effect:
> stopifnot(identical(c(d1), c(daisy(d5[,-4], type = list(asymm = 1:4)))))
> 
> ###---- Trivial "binary only" matrices (not data frames) did fail:
> 
> x <- matrix(0, 2, 2)
> dimnames(x)[[2]] <- c("A", "B")## colnames<- is missing in S+
> daisy(x, type = list(symm= "B", asymm="A"))
Dissimilarities :
  1
2 0

Metric :  mixed ;  Types = A, S 
Number of objects : 2
Warning message:
In daisy(x, type = list(symm = "B", asymm = "A")) :
  at least one binary variable has not 2 different levels.
> daisy(x, type = list(symm= "B"))# 0 too
Dissimilarities :
  1
2 0

Metric :  mixed ;  Types = I, S 
Number of objects : 2
Warning message:
In daisy(x, type = list(symm = "B")) :
  at least one binary variable has not 2 different levels.
> 
> x2 <- x; x2[2,2] <- 1
> daisy(x2, type= list(symm = "B"))# |-> 0.5  (gives 1 in S+)
Dissimilarities :
    1
2 0.5

Metric :  mixed ;  Types = I, S 
Number of objects : 2
> daisy(x2, type= list(symm = "B", asymm="A"))# 1
Dissimilarities :
  1
2 1

Metric :  mixed ;  Types = A, S 
Number of objects : 2
Warning message:
In daisy(x2, type = list(symm = "B", asymm = "A")) :
  at least one binary variable has not 2 different levels.
> 
> x3 <- x; x3[] <- diag(2)
> daisy(x3) # warning: both as interval scaled -> sqrt(2)
Dissimilarities :
         1
2 1.414214

Metric :  euclidean 
Number of objects : 2
> daisy(x3, type= list(symm="B", asymm="A"))#  1
Dissimilarities :
  1
2 1

Metric :  mixed ;  Types = A, S 
Number of objects : 2
> daisy(x3, type= list(symm =c("B","A")))   #  1, S+: sqrt(2)
Dissimilarities :
  1
2 1

Metric :  mixed ;  Types = S, S 
Number of objects : 2
> daisy(x3, type= list(asymm=c("B","A")))   #  1, S+ : sqrt(2)
Dissimilarities :
  1
2 1

Metric :  mixed ;  Types = A, A 
Number of objects : 2
> 
> x4 <- rbind(x3, 1)
> daisy(x4, type= list(symm="B", asymm="A"))# 1   0.5 0.5
Dissimilarities :
    1   2
2 1.0    
3 0.5 0.5

Metric :  mixed ;  Types = A, S 
Number of objects : 3
> daisy(x4, type= list(symm=c("B","A")))    # dito;  S+ : 1.41  1   1
Dissimilarities :
    1   2
2 1.0    
3 0.5 0.5

Metric :  mixed ;  Types = S, S 
Number of objects : 3
> daisy(x4, type= list(asymm=c("A","B")))   # dito,     dito
Dissimilarities :
    1   2
2 1.0    
3 0.5 0.5

Metric :  mixed ;  Types = A, A 
Number of objects : 3
> 
> 
> 
> ## ----------- example(daisy) -----------------------
> 
> data(flower)
> data(agriculture)
> 
> ## Example 1 in ref:
> ##  Dissimilarities using Euclidean metric and without standardization
> (d.agr  <- daisy(agriculture, metric = "euclidean", stand = FALSE))
Dissimilarities :
            B        DK         D        GR         E         F       IRL
DK   5.408327                                                            
D    2.061553  3.405877                                                  
GR  22.339651 22.570113 22.661200                                        
E    9.818350 11.182576 10.394710 12.567418                              
F    3.448188  3.512834  2.657066 20.100995  8.060397                    
IRL 12.747549 13.306014 13.080138  9.604166  3.140064 10.564563          
I    5.803447  5.470832  5.423099 17.383325  5.727128  2.773085  7.920859
L    4.275512  2.220360  2.300000 24.035391 12.121056  4.060788 14.569145
NL   1.649242  5.096077  2.435159 20.752349  8.280097  2.202272 11.150785
P   17.236299 17.864490 17.664088  5.162364  7.430343 15.164432  4.601087
UK   2.828427  8.052950  4.850773 21.485344  8.984431  5.303772 12.103718
            I         L        NL         P
DK                                         
D                                          
GR                                         
E                                          
F                                          
IRL                                        
I                                          
L    6.660330                              
NL   4.204759  4.669047                    
P   12.515990 19.168985 15.670673          
UK   6.723095  7.102112  3.124100 16.323296

Metric :  euclidean 
Number of objects : 12
> (d.agr2 <- daisy(agriculture, metric = "manhattan"))
Dissimilarities :
       B   DK    D   GR    E    F  IRL    I    L   NL    P
DK   7.5                                                  
D    2.7  4.8                                             
GR  30.4 31.9 31.5                                        
E   13.6 15.1 14.7 16.8                                   
F    4.3  3.8  3.4 28.1 11.3                              
IRL 17.2 18.7 18.3 13.2  3.6 14.9                         
I    6.0  7.5  7.1 24.4  7.6  3.7 11.2                    
L    5.0  2.5  2.3 33.8 17.0  5.7 20.6  9.4               
NL   2.0  6.3  3.1 28.4 11.6  3.1 15.2  4.4  5.4          
P   23.7 25.2 24.8  6.7 10.1 21.4  6.5 17.7 27.1 21.7     
UK   3.2 10.7  5.9 28.0 11.2  7.5 14.8  8.8  8.2  4.4 21.3

Metric :  manhattan 
Number of objects : 12
> 
> 
> ## Example 2 in ref
> (dfl0 <- daisy(flower))
Dissimilarities :
           1         2         3         4         5         6         7
2  0.8875408                                                            
3  0.5272467 0.5147059                                                  
4  0.3517974 0.5504493 0.5651552                                        
5  0.4115605 0.6226307 0.3726307 0.6383578                              
6  0.2269199 0.6606209 0.3003268 0.4189951 0.3443627                    
7  0.2876225 0.5999183 0.4896242 0.3435866 0.4197712 0.1892974          
8  0.4234069 0.4641340 0.6038399 0.2960376 0.4673203 0.5714869 0.4107843
9  0.5808824 0.4316585 0.4463644 0.8076797 0.3306781 0.5136846 0.5890931
10 0.6094363 0.4531046 0.4678105 0.5570670 0.3812908 0.4119281 0.5865196
11 0.3278595 0.7096814 0.5993873 0.6518791 0.3864788 0.4828840 0.5652369
12 0.4267565 0.5857843 0.6004902 0.5132761 0.5000817 0.5248366 0.6391340
13 0.5196487 0.5248366 0.5395425 0.7464461 0.2919118 0.4524510 0.5278595
14 0.2926062 0.5949346 0.6096405 0.3680147 0.5203431 0.3656863 0.5049837
15 0.6221814 0.3903595 0.5300654 0.5531454 0.4602124 0.5091503 0.3345588
16 0.6935866 0.3575163 0.6222222 0.3417892 0.7301471 0.5107843 0.4353758
17 0.7765114 0.1904412 0.5801471 0.4247141 0.6880719 0.5937092 0.5183007
18 0.4610294 0.4515114 0.7162173 0.4378268 0.4755310 0.6438317 0.4692402
           8         9        10        11        12        13        14
2                                                                       
3                                                                       
4                                                                       
5                                                                       
6                                                                       
7                                                                       
8                                                                       
9  0.6366422                                                            
10 0.6639706 0.4256127                                                  
11 0.4955474 0.4308007 0.3948121                                        
12 0.4216503 0.4194036 0.3812092 0.2636029                              
13 0.5754085 0.2181781 0.3643791 0.3445670 0.2331699                    
14 0.4558007 0.4396650 0.3609477 0.2838644 0.1591503 0.3784314          
15 0.4512255 0.2545343 0.4210784 0.4806781 0.4295752 0.3183007 0.4351307
16 0.6378268 0.6494690 0.3488562 0.7436683 0.6050654 0.5882353 0.4598039
17 0.4707516 0.6073938 0.3067810 0.7015931 0.5629902 0.5461601 0.5427288
18 0.1417892 0.5198529 0.8057598 0.5359477 0.5495507 0.5733252 0.5698121
          15        16        17
2                               
3                               
4                               
5                               
6                               
7                               
8                               
9                               
10                              
11                              
12                              
13                              
14                              
15                              
16 0.3949346                    
17 0.3528595 0.1670752          
18 0.5096814 0.7796160 0.6125408

Metric :  mixed ;  Types = N, N, N, N, O, O, I, I 
Number of objects : 18
> stopifnot(identical(c(dfl0),
+                     c(daisy(flower, type = list(symm = 1)))) &&
+           identical(c(dfl0),
+                     c(daisy(flower, type = list(symm = 2)))) &&
+           identical(c(dfl0),
+                     c(daisy(flower, type = list(symm = 3)))) &&
+           identical(c(dfl0),
+                     c(daisy(flower, type = list(symm = c(1,3)))))
+          )
> 
> (dfl1 <- daisy(flower, type = list(asymm = 3)))
Dissimilarities :
           1         2         3         4         5         6         7
2  0.8875408                                                            
3  0.5272467 0.5882353                                                  
4  0.3517974 0.5504493 0.5651552                                        
5  0.4115605 0.7115780 0.4258637 0.6383578                              
6  0.2269199 0.7549953 0.3432306 0.4189951 0.3935574                    
7  0.2876225 0.6856209 0.5595705 0.3435866 0.4797386 0.2163399          
8  0.4234069 0.4641340 0.6038399 0.2960376 0.4673203 0.5714869 0.4107843
9  0.5808824 0.4933240 0.5101307 0.8076797 0.3779178 0.5870682 0.6732493
10 0.6094363 0.5178338 0.5346405 0.5570670 0.4357610 0.4707750 0.6703081
11 0.3278595 0.7096814 0.5993873 0.6518791 0.3864788 0.4828840 0.5652369
12 0.4267565 0.5857843 0.6004902 0.5132761 0.5000817 0.5248366 0.6391340
13 0.5196487 0.5998133 0.6166200 0.7464461 0.3336134 0.5170868 0.6032680
14 0.2926062 0.5949346 0.6096405 0.3680147 0.5203431 0.3656863 0.5049837
15 0.6221814 0.4461251 0.6057890 0.5531454 0.5259570 0.5818861 0.3823529
16 0.6935866 0.4085901 0.7111111 0.3417892 0.8344538 0.5837535 0.4975724
17 0.7765114 0.2176471 0.6630252 0.4247141 0.7863679 0.6785247 0.5923436
18 0.4610294 0.4515114 0.7162173 0.4378268 0.4755310 0.6438317 0.4692402
           8         9        10        11        12        13        14
2                                                                       
3                                                                       
4                                                                       
5                                                                       
6                                                                       
7                                                                       
8                                                                       
9  0.6366422                                                            
10 0.6639706 0.4864146                                                  
11 0.4955474 0.4308007 0.3948121                                        
12 0.4216503 0.4194036 0.3812092 0.2636029                              
13 0.5754085 0.2493464 0.4164332 0.3445670 0.2331699                    
14 0.4558007 0.4396650 0.3609477 0.2838644 0.1591503 0.3784314          
15 0.4512255 0.2908964 0.4812325 0.4806781 0.4295752 0.3637722 0.4351307
16 0.6378268 0.7422502 0.3986928 0.7436683 0.6050654 0.6722689 0.4598039
17 0.4707516 0.6941643 0.3506069 0.7015931 0.5629902 0.6241830 0.5427288
18 0.1417892 0.5198529 0.8057598 0.5359477 0.5495507 0.5733252 0.5698121
          15        16        17
2                               
3                               
4                               
5                               
6                               
7                               
8                               
9                               
10                              
11                              
12                              
13                              
14                              
15                              
16 0.4513539                    
17 0.4032680 0.1909430          
18 0.5096814 0.7796160 0.6125408

Metric :  mixed ;  Types = N, N, A, N, O, O, I, I 
Number of objects : 18
> (dfl2 <- daisy(flower, type = list(asymm = c(1, 3), ordratio = 7)))
Dissimilarities :
           1         2         3         4         5         6         7
2  0.9007353                                                            
3  0.6176471 0.5882353                                                  
4  0.4226891 0.5455882 0.6403361                                        
5  0.4806723 0.7369748 0.5264706 0.7605042                              
6  0.2823529 0.7470588 0.3911765 0.4764706 0.4980392                    
7  0.3310924 0.6983193 0.6676471 0.4109244 0.5745098 0.2764706          
8  0.5100840 0.4544118 0.6789916 0.3327731 0.5705882 0.6563025 0.4932773
9  0.5808824 0.5084034 0.5252101 0.8257353 0.3882353 0.6100840 0.6756303
10 0.6323529 0.5067227 0.5235294 0.5522059 0.4722689 0.4739496 0.6941176
11 0.3389706 0.7117647 0.6014706 0.6588235 0.4066176 0.4919118 0.5742647
12 0.4441176 0.5816176 0.5963235 0.5139706 0.5264706 0.5220588 0.6544118
13 0.5286765 0.6252101 0.6420168 0.7735294 0.3336134 0.5504202 0.6159664
14 0.3044118 0.5963235 0.6110294 0.3742647 0.5411765 0.3573529 0.5147059
15 0.6242647 0.4588235 0.6184874 0.5691176 0.5386555 0.6025210 0.3823529
16 0.6845588 0.3831933 0.6857143 0.3147059 0.8344538 0.5504202 0.4848739
17 0.7897059 0.2176471 0.6630252 0.4198529 0.8117647 0.6705882 0.6050420
18 0.5268908 0.4647059 0.8336134 0.5210084 0.5537815 0.7588235 0.5386555
           8         9        10        11        12        13        14
2                                                                       
3                                                                       
4                                                                       
5                                                                       
6                                                                       
7                                                                       
8                                                                       
9  0.6595588                                                            
10 0.6639706 0.5126050                                                  
11 0.5073529 0.4419118 0.4066176                                        
12 0.4272059 0.4367647 0.3867647 0.2698529                              
13 0.6073529 0.2596639 0.4529412 0.3647059 0.2595588                    
14 0.4669118 0.4514706 0.3720588 0.2845588 0.1647059 0.3992647          
15 0.4720588 0.2932773 0.5050420 0.4897059 0.4448529 0.3764706 0.4448529
16 0.6058824 0.7319328 0.3621849 0.7235294 0.5786765 0.6722689 0.4389706
17 0.4610294 0.7092437 0.3394958 0.7036765 0.5588235 0.6495798 0.5441176
18 0.1882353 0.5198529 0.8286765 0.5470588 0.5669118 0.5823529 0.5816176
          15        16        17
2                               
3                               
4                               
5                               
6                               
7                               
8                               
9                               
10                              
11                              
12                              
13                              
14                              
15                              
16 0.4386555                    
17 0.4159664 0.1655462          
18 0.5117647 0.7705882 0.6257353

Metric :  mixed ;  Types = A, N, A, N, O, O, T, I 
Number of objects : 18
> (dfl3 <- daisy(flower, type = list(asymm = 1:3)))
Dissimilarities :
           1         2         3         4         5         6         7
2  0.8875408                                                            
3  0.6025677 0.5882353                                                  
4  0.4020542 0.6290850 0.6458917                                        
5  0.4703548 0.7115780 0.4968410 0.7295518                              
6  0.2593371 0.7549953 0.4004357 0.4788515 0.4591503                    
7  0.3287115 0.7998911 0.6528322 0.4581155 0.5596950 0.2523965          
8  0.4838936 0.5304388 0.6901027 0.3947168 0.5340803 0.6531279 0.5477124
9  0.5808824 0.4933240 0.5101307 0.8076797 0.3779178 0.5870682 0.6732493
10 0.6094363 0.5178338 0.5346405 0.5570670 0.4357610 0.4707750 0.6703081
11 0.3278595 0.7096814 0.5993873 0.6518791 0.3864788 0.4828840 0.5652369
12 0.4267565 0.5857843 0.6004902 0.5132761 0.5000817 0.5248366 0.6391340
13 0.5196487 0.5998133 0.6166200 0.7464461 0.3336134 0.5170868 0.6032680
14 0.2926062 0.5949346 0.6096405 0.3680147 0.5203431 0.3656863 0.5049837
15 0.6221814 0.5204793 0.6057890 0.6321662 0.5259570 0.5818861 0.4460784
16 0.6935866 0.4766885 0.7111111 0.3906162 0.8344538 0.5837535 0.5805011
17 0.7765114 0.2539216 0.6630252 0.4853875 0.7863679 0.6785247 0.6910675
18 0.5268908 0.5160131 0.8185341 0.5837691 0.5434641 0.7358077 0.6256536
           8         9        10        11        12        13        14
2                                                                       
3                                                                       
4                                                                       
5                                                                       
6                                                                       
7                                                                       
8                                                                       
9  0.6366422                                                            
10 0.6639706 0.4864146                                                  
11 0.4955474 0.4308007 0.3948121                                        
12 0.4216503 0.4194036 0.3812092 0.2636029                              
13 0.5754085 0.2493464 0.4164332 0.3445670 0.2331699                    
14 0.4558007 0.4396650 0.3609477 0.2838644 0.1591503 0.3784314          
15 0.5156863 0.2908964 0.4812325 0.4806781 0.4295752 0.3637722 0.4351307
16 0.7289449 0.7422502 0.3986928 0.7436683 0.6050654 0.6722689 0.4598039
17 0.5380019 0.6941643 0.3506069 0.7015931 0.5629902 0.6241830 0.5427288
18 0.1890523 0.5198529 0.8057598 0.5359477 0.5495507 0.5733252 0.5698121
          15        16        17
2                               
3                               
4                               
5                               
6                               
7                               
8                               
9                               
10                              
11                              
12                              
13                              
14                              
15                              
16 0.5265795                    
17 0.4704793 0.2227669          
18 0.5824930 0.8909897 0.7000467

Metric :  mixed ;  Types = A, A, A, N, O, O, I, I 
Number of objects : 18
> 
> ## --- animals
> data(animals)
> d0 <- daisy(animals)
Warning message:
In daisy(animals) :
  binary variable(s) 1, 2, 3, 4, 5, 6 treated as interval scaled
> 
> d1 <- daisy(animals - 1, type=list(asymm=c(2,4)))
Warning message:
In daisy(animals - 1, type = list(asymm = c(2, 4))) :
  binary variable(s) 1, 3, 5, 6 treated as interval scaled
> (d2 <- daisy(animals - 1, type=list(symm = c(1,3,5,6), asymm=c(2,4))))
Dissimilarities :
          ant       bee       cat       cpl       chi       cow       duc
bee 0.4000000                                                            
cat 1.0000000 0.8000000                                                  
cpl 0.5000000 0.4000000 0.5000000                                        
chi 0.8000000 0.6666667 0.4000000 0.8000000                              
cow 0.7500000 0.6000000 0.2500000 0.7500000 0.2000000                    
duc 0.6000000 0.6000000 0.6000000 1.0000000 0.5000000 0.4000000          
eag 0.8333333 0.8333333 0.5000000 0.8333333 0.5000000 0.6666667 0.3333333
ele 0.6000000 0.8333333 0.6000000 1.0000000 0.2000000 0.4000000 0.3333333
fly 0.4000000 0.4000000 0.8000000 0.4000000 1.0000000 1.0000000 0.6000000
fro 0.5000000 0.8000000 0.7500000 0.7500000 0.5000000 0.7500000 0.6000000
her 0.2500000 0.6000000 0.7500000 0.7500000 0.6000000 0.5000000 0.4000000
lio 0.7500000 0.6000000 0.2500000 0.7500000 0.0000000 0.0000000 0.4000000
liz 0.5000000 0.8000000 0.5000000 0.5000000 0.8000000 0.7500000 0.6000000
lob 0.0000000 0.5000000 1.0000000 0.3333333 1.0000000 1.0000000 0.7500000
man 0.8000000 0.6666667 0.4000000 0.8000000 0.0000000 0.2000000 0.5000000
rab 0.7500000 0.6000000 0.2500000 0.7500000 0.2000000 0.0000000 0.4000000
sal 0.3333333 0.7500000 0.6666667 0.6666667 0.7500000 0.6666667 0.5000000
spi 0.5000000 0.4000000 0.5000000 0.0000000 0.7500000 0.7500000 1.0000000
wha 0.6000000 0.8333333 0.6000000 1.0000000 0.2000000 0.4000000 0.3333333
          eag       ele       fly       fro       her       lio       liz
bee                                                                      
cat                                                                      
cpl                                                                      
chi                                                                      
cow                                                                      
duc                                                                      
eag                                                                      
ele 0.3333333                                                            
fly 0.5000000 0.8333333                                                  
fro 0.4000000 0.2500000 0.6000000                                        
her 0.6666667 0.4000000 0.6000000 0.2500000                              
lio 0.6000000 0.2500000 1.0000000 0.6666667 0.5000000                    
liz 0.5000000 0.6000000 0.4000000 0.2500000 0.2500000 0.7500000          
lob 0.8000000 0.7500000 0.2500000 0.5000000 0.3333333 1.0000000 0.3333333
man 0.5000000 0.2000000 1.0000000 0.5000000 0.6000000 0.0000000 0.8000000
rab 0.6666667 0.4000000 1.0000000 0.7500000 0.5000000 0.0000000 0.7500000
sal 0.6000000 0.5000000 0.5000000 0.2500000 0.0000000 0.6666667 0.0000000
spi 0.8000000 1.0000000 0.4000000 0.6666667 0.7500000 0.7500000 0.5000000
wha 0.3333333 0.0000000 0.8333333 0.2500000 0.4000000 0.2500000 0.6000000
          lob       man       rab       sal       spi
bee                                                  
cat                                                  
cpl                                                  
chi                                                  
cow                                                  
duc                                                  
eag                                                  
ele                                                  
fly                                                  
fro                                                  
her                                                  
lio                                                  
liz                                                  
lob                                                  
man 1.0000000                                        
rab 1.0000000 0.2000000                              
sal 0.3333333 0.7500000 0.6666667                    
spi 0.3333333 0.7500000 0.7500000 0.6666667          
wha 0.7500000 0.2000000 0.4000000 0.5000000 1.0000000

Metric :  mixed ;  Types = S, A, S, A, S, S 
Number of objects : 20
> stopifnot(c(d1) == c(d2))
> 
> d3 <- daisy(2 - animals, type=list(asymm=c(2,4)))
Warning message:
In daisy(2 - animals, type = list(asymm = c(2, 4))) :
  binary variable(s) 1, 3, 5, 6 treated as interval scaled
> (d4 <- daisy(2 - animals, type=list(symm = c(1,3,5,6), asymm=c(2,4))))
Dissimilarities :
          ant       bee       cat       cpl       chi       cow       duc
bee 0.3333333                                                            
cat 0.6666667 0.6666667                                                  
cpl 0.3333333 0.3333333 0.3333333                                        
chi 0.6666667 0.6666667 0.3333333 0.6666667                              
cow 0.5000000 0.5000000 0.1666667 0.5000000 0.1666667                    
duc 0.5000000 0.6000000 0.5000000 0.8333333 0.5000000 0.3333333          
eag 0.8333333 1.0000000 0.5000000 0.8333333 0.6000000 0.6666667 0.4000000
ele 0.5000000 0.8333333 0.5000000 0.8333333 0.2000000 0.3333333 0.3333333
fly 0.3333333 0.4000000 0.6666667 0.3333333 1.0000000 0.8333333 0.6000000
fro 0.4000000 0.8000000 0.6000000 0.6000000 0.5000000 0.6000000 0.6000000
her 0.1666667 0.5000000 0.5000000 0.5000000 0.5000000 0.3333333 0.3333333
lio 0.6000000 0.6000000 0.2000000 0.6000000 0.0000000 0.0000000 0.4000000
liz 0.3333333 0.6666667 0.3333333 0.3333333 0.6666667 0.5000000 0.5000000
lob 0.0000000 0.4000000 0.6000000 0.2000000 0.8000000 0.6000000 0.6000000
man 0.6666667 0.6666667 0.3333333 0.6666667 0.0000000 0.1666667 0.5000000
rab 0.5000000 0.5000000 0.1666667 0.5000000 0.1666667 0.0000000 0.3333333
sal 0.2000000 0.6000000 0.4000000 0.4000000 0.6000000 0.4000000 0.4000000
spi 0.4000000 0.4000000 0.4000000 0.0000000 0.6000000 0.6000000 1.0000000
wha 0.5000000 0.8333333 0.5000000 0.8333333 0.2000000 0.3333333 0.3333333
          eag       ele       fly       fro       her       lio       liz
bee                                                                      
cat                                                                      
cpl                                                                      
chi                                                                      
cow                                                                      
duc                                                                      
eag                                                                      
ele 0.4000000                                                            
fly 0.6000000 0.8333333                                                  
fro 0.5000000 0.2500000 0.6000000                                        
her 0.6666667 0.3333333 0.5000000 0.2000000                              
lio 0.6000000 0.2000000 1.0000000 0.5000000 0.4000000                    
liz 0.5000000 0.5000000 0.3333333 0.2000000 0.1666667 0.6000000          
lob 0.8000000 0.6000000 0.2000000 0.4000000 0.2000000 0.7500000 0.2000000
man 0.6000000 0.2000000 1.0000000 0.5000000 0.5000000 0.0000000 0.6666667
rab 0.6666667 0.3333333 0.8333333 0.6000000 0.3333333 0.0000000 0.5000000
sal 0.6000000 0.4000000 0.4000000 0.2000000 0.0000000 0.5000000 0.0000000
spi 0.8000000 0.8000000 0.4000000 0.5000000 0.6000000 0.6000000 0.4000000
wha 0.4000000 0.0000000 0.8333333 0.2500000 0.3333333 0.2000000 0.5000000
          lob       man       rab       sal       spi
bee                                                  
cat                                                  
cpl                                                  
chi                                                  
cow                                                  
duc                                                  
eag                                                  
ele                                                  
fly                                                  
fro                                                  
her                                                  
lio                                                  
liz                                                  
lob                                                  
man 0.8000000                                        
rab 0.6000000 0.1666667                              
sal 0.2000000 0.6000000 0.4000000                    
spi 0.2500000 0.6000000 0.6000000 0.5000000          
wha 0.6000000 0.2000000 0.3333333 0.4000000 0.8000000

Metric :  mixed ;  Types = S, A, S, A, S, S 
Number of objects : 20
> stopifnot(c(d3) == c(d4))
> 
> pairs(cbind(d0,d2,d4),
+       main = "Animals -- symmetric and asymm. dissimilarities")
> 
> proc.time()
   user  system elapsed 
  0.518   0.113   0.905