====== Zoo ======
[[vlado:work:sda:clu|SDA clustering]]
It seems that there are some problems with data frames with a single variable. A fast solution is to add another "skip" variable.
> wdir <- "C:/Users/vlado/docs/papers/2023/SDA/test"
> setwd(wdir)
> library(jsonlite)
> source("https://raw.githubusercontent.com/bavla/SDA/main/code/symclus.R")
> SD <- fromJSON("https://raw.githubusercontent.com/bavla/symData/master/SDAJSON/ZooSDA.json")
> # str(SD)
> # artificial second variable because of problems with a single variable
> nUnits <- SD$head$nUnits; u <- vector("list",nUnits)
> for(i in 1:nUnits) u[[i]] <- c(1,2)
> SD$SDF$skip <- u
> date()
[1] "Mon Oct 30 02:50:20 2023"
> dSel <- list( list(var=4,dType="membersR",d=dMembers,alpha=1),
+ list(var=5,dType="intervalSq",d=dIntSq,alpha=0))
> nSel <- length(dSel); alpha <- rep(NA,nSel)
> for(i in 1:nSel) alpha[i] <- dSel[[i]]$alpha
> # hc <- hclustTest(SD,dSel)
> hc <- hclustSO(SD,dSel)
> plot(hc,hang=-1)
> plot(hc,hang=-1,cex=0.7)
To add (manually in Inkscape) the leaders of the top-level clusters in the dendrogram.
> m <- hc$merge
> dim(m)
[1] 100 2
> m[90:100,]
[,1] [,2]
[1,] 70 81
[2,] 84 75
[3,] 82 78
[4,] 89 86
[5,] 90 83
[6,] 85 91
[7,] 88 87
[8,] 93 94
[9,] 92 95
[10,] 96 98
[11,] 97 99
> lab <- SD$head$vars$V4$cats
> for(i in 80:100) cat(i,":",lab[as.logical(hc$leaders$battrs[[i]]$L)],"\n")
80 : eggs aquatic predator toothed backbone fins tail
81 : hair milk toothed backbone breathes tail catsize
82 : hair eggs airborne breathes
83 : hair milk predator toothed backbone breathes tail catsize
84 : feathers eggs airborne aquatic predator backbone breathes tail
85 : feathers eggs backbone breathes tail catsize
86 : hair eggs milk aquatic predator toothed backbone breathes tail domestic
87 : eggs aquatic predator toothed backbone fins tail
88 : eggs aquatic predator toothed backbone breathes tail
89 : hair milk aquatic predator toothed backbone breathes tail catsize
90 : hair milk toothed backbone breathes tail catsize
91 : feathers eggs airborne backbone breathes tail
92 : eggs airborne breathes
93 : hair eggs milk aquatic predator toothed backbone breathes tail catsize
94 : hair milk predator toothed backbone breathes tail catsize
95 : feathers eggs airborne backbone breathes tail
96 : eggs aquatic predator toothed backbone fins tail
97 : hair milk predator toothed backbone breathes tail catsize
98 : feathers eggs airborne backbone breathes tail
99 : eggs predator backbone breathes tail
100 : hair eggs predator toothed backbone breathes tail catsize
{{https://github.com/bavla/symData/blob/master/SDAJSON/ZooDendroL.pdf}}