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