Пример вызова встроенной справки
agnes> data(votes.repub)
agnes> agn1 <- agnes(votes.repub, metric = "manhattan", stand = TRUE)
agnes> agn1
Call: agnes(x = votes.repub, metric = "manhattan", stand = TRUE)
Agglomerative coefficient: 0.7977555
Order of objects:
[1] Alabama Georgia Arkansas Louisiana Mississippi
[6] South Carolina Alaska Vermont Arizona Montana
[11] Nevada Colorado Idaho Wyoming Utah
[16] California Oregon Washington Minnesota Connecticut
[21] New York New Jersey Illinois Ohio Indiana
[26] Michigan Pennsylvania New Hampshire Wisconsin Delaware
[31] Kentucky Maryland Missouri New Mexico West Virginia
[36] Iowa South Dakota North Dakota Kansas Nebraska
[41] Maine Massachusetts Rhode Island Florida North Carolina
[46] Tennessee Virginia Oklahoma Hawaii Texas
Height (summary):
Min. 1st Qu. Median Mean 3rd Qu. Max.
8.382 12.800 18.530 23.120 28.410 87.460
Available components:
[1] "order" "height" "ac" "merge" "diss" "call"
[7] "method" "order.lab" "data"
agnes> plot(agn1)

agnes> op <- par(mfrow=c(2,2))
agnes> agn2 <- agnes(daisy(votes.repub), diss = TRUE, method = "complete")
agnes> plot(agn2)
agnes> ## alpha = 0.625 ==> beta = -1/4 is "recommended" by some
agnes> agnS <- agnes(votes.repub, method = "flexible", par.meth = 0.625)
agnes> plot(agnS)

agnes> par(op)
agnes> ## "show" equivalence of three "flexible" special cases
agnes> d.vr <- daisy(votes.repub)
agnes> a.wgt <- agnes(d.vr, method = "weighted")
agnes> a.sing <- agnes(d.vr, method = "single")
agnes> a.comp <- agnes(d.vr, method = "complete")
agnes> iC <- -(6:7) # not using 'call' and 'method' for comparisons
agnes> stopifnot(
agnes+ all.equal(a.wgt [iC], agnes(d.vr, method="flexible", par.method = 0.5)[iC]) ,
agnes+ all.equal(a.sing[iC], agnes(d.vr, method="flex", par.method= c(.5,.5,0, -.5))[iC]),
agnes+ all.equal(a.comp[iC], agnes(d.vr, method="flex", par.method= c(.5,.5,0, +.5))[iC]))
agnes> ## Exploring the dendrogram structure
agnes> (d2 <- as.dendrogram(agn2)) # two main branches
'dendrogram' with 2 branches and 50 members total, at height 281.9508
agnes> d2[[1]] # the first branch
'dendrogram' with 2 branches and 8 members total, at height 116.7048
agnes> d2[[2]] # the 2nd one { 8 + 42 = 50 }
'dendrogram' with 2 branches and 42 members total, at height 178.4119
agnes> d2[[1]][[1]]# first sub-branch of branch 1 .. and shorter form
'dendrogram' with 2 branches and 6 members total, at height 72.92212
agnes> identical(d2[[c(1,1)]],
agnes+ d2[[1]][[1]])
[1] TRUE
agnes> ## a "textual picture" of the dendrogram :
agnes> str(d2)
--[dendrogram w/ 2 branches and 50 members at h = 282]
|--[dendrogram w/ 2 branches and 8 members at h = 117]
| |--[dendrogram w/ 2 branches and 6 members at h = 72.9]
| | |--[dendrogram w/ 2 branches and 3 members at h = 60.9]
| | | |--[dendrogram w/ 2 branches and 2 members at h = 48.2]
| | | | |--leaf "Alabama"
| | | | `--leaf "Georgia"
| | | `--leaf "Louisiana"
| | `--[dendrogram w/ 2 branches and 3 members at h = 58.8]
| | |--[dendrogram w/ 2 branches and 2 members at h = 56.1]
| | | |--leaf "Arkansas"
| | | `--leaf "Florida"
| | `--leaf "Texas"
| `--[dendrogram w/ 2 branches and 2 members at h = 63.1]
| |--leaf "Mississippi"
| `--leaf "South Carolina"
`--[dendrogram w/ 2 branches and 42 members at h = 178]
|--[dendrogram w/ 2 branches and 37 members at h = 121]
| |--[dendrogram w/ 2 branches and 31 members at h = 80.5]
| | |--[dendrogram w/ 2 branches and 17 members at h = 64.5]
| | | |--[dendrogram w/ 2 branches and 13 members at h = 56.4]
| | | | |--[dendrogram w/ 2 branches and 10 members at h = 47.2]
| | | | | |--[dendrogram w/ 2 branches and 2 members at h = 28.1]
| | | | | | |--leaf "Alaska"
| | | | | | `--leaf "Michigan"
| | | | | `--[dendrogram w/ 2 branches and 8 members at h = 39.2]
| | | | | |--[dendrogram w/ 2 branches and 5 members at h = 36.8]
| | | | | | |--[dendrogram w/ 2 branches and 3 members at h = 32.9]
| | | | | | | |--[dendrogram w/ 2 branches and 2 members at h = 19.4]
| | | | | | | | |--leaf "Connecticut"
| | | | | | | | `--leaf "New York"
| | | | | | | `--leaf "New Hampshire"
| | | | | | `--[dendrogram w/ 2 branches and 2 members at h = 20.2]
| | | | | | |--leaf "Indiana"
| | | | | | `--leaf "Ohio"
| | | | | `--[dendrogram w/ 2 branches and 3 members at h = 25.3]
| | | | | |--[dendrogram w/ 2 branches and 2 members at h = 20.9]
| | | | | | |--leaf "Illinois"
| | | | | | `--leaf "New Jersey"
| | | | | `--leaf "Pennsylvania"
| | | | `--[dendrogram w/ 2 branches and 3 members at h = 42.2]
| | | | |--leaf "Minnesota"
| | | | `--[dendrogram w/ 2 branches and 2 members at h = 33.7]
| | | | |--leaf "North Dakota"
| | | | `--leaf "Wisconsin"
| | | `--[dendrogram w/ 2 branches and 4 members at h = 37.5]
| | | |--[dendrogram w/ 2 branches and 2 members at h = 26.2]
| | | | |--leaf "Iowa"
| | | | `--leaf "South Dakota"
| | | `--[dendrogram w/ 2 branches and 2 members at h = 25.9]
| | | |--leaf "Kansas"
| | | `--leaf "Nebraska"
| | `--[dendrogram w/ 2 branches and 14 members at h = 70.5]
| | |--[dendrogram w/ 2 branches and 8 members at h = 48]
| | | |--[dendrogram w/ 2 branches and 4 members at h = 43.4]
| | | | |--[dendrogram w/ 2 branches and 3 members at h = 27.8]
| | | | | |--[dendrogram w/ 2 branches and 2 members at h = 23.4]
| | | | | | |--leaf "Arizona"
| | | | | | `--leaf "Nevada"
| | | | | `--leaf "Montana"
| | | | `--leaf "Oklahoma"
| | | `--[dendrogram w/ 2 branches and 4 members at h = 43.7]
| | | |--leaf "Colorado"
| | | `--[dendrogram w/ 2 branches and 3 members at h = 31.2]
| | | |--[dendrogram w/ 2 branches and 2 members at h = 17.2]
| | | | |--leaf "Idaho"
| | | | `--leaf "Wyoming"
| | | `--leaf "Utah"
| | `--[dendrogram w/ 2 branches and 6 members at h = 54.3]
| | |--[dendrogram w/ 2 branches and 3 members at h = 33.2]
| | | |--leaf "California"
| | | `--[dendrogram w/ 2 branches and 2 members at h = 22.2]
| | | |--leaf "Oregon"
| | | `--leaf "Washington"
| | `--[dendrogram w/ 2 branches and 3 members at h = 35.1]
| | |--[dendrogram w/ 2 branches and 2 members at h = 21.1]
| | | |--leaf "Missouri"
| | | `--leaf "New Mexico"
| | `--leaf "West Virginia"
| `--[dendrogram w/ 2 branches and 6 members at h = 66.8]
| |--[dendrogram w/ 2 branches and 3 members at h = 43.4]
| | |--leaf "Delaware"
| | `--[dendrogram w/ 2 branches and 2 members at h = 33.5]
| | |--leaf "Kentucky"
| | `--leaf "Maryland"
| `--[dendrogram w/ 2 branches and 3 members at h = 30.2]
| |--[dendrogram w/ 2 branches and 2 members at h = 29.5]
| | |--leaf "North Carolina"
| | `--leaf "Tennessee"
| `--leaf "Virginia"
`--[dendrogram w/ 2 branches and 5 members at h = 83.1]
|--[dendrogram w/ 2 branches and 4 members at h = 55.4]
| |--[dendrogram w/ 2 branches and 2 members at h = 32.8]
| | |--leaf "Hawaii"
| | `--leaf "Maine"
| `--[dendrogram w/ 2 branches and 2 members at h = 22.6]
| |--leaf "Massachusetts"
| `--leaf "Rhode Island"
`--leaf "Vermont"
agnes> data(agriculture)
agnes> ## Plot similar to Figure 7 in ref
agnes> ## Not run: plot(agnes(agriculture), ask = TRUE)
agnes> ## Don't show:
agnes> plot(agnes(agriculture))


agnes> ## End(Don't show)
agnes>
agnes> data(animals)
agnes> aa.a <- agnes(animals) # default method = "average"
agnes> aa.ga <- agnes(animals, method = "gaverage")
agnes> op <- par(mfcol=1:2, mgp=c(1.5, 0.6, 0), mar=c(.1+ c(4,3,2,1)),
agnes+ cex.main=0.8)
agnes> plot(aa.a, which.plot = 2)
agnes> plot(aa.ga, which.plot = 2)

agnes> par(op)
agnes> ## Don't show:
agnes> ## equivalence
agnes> stopifnot( ## below show ave == gave(0); here ave == gave(c(1,1,0,0)):
agnes+ all.equal(aa.a [iC], agnes(animals, method="gave", par.meth= c(1,1,0,0))[iC]),
agnes+ all.equal(aa.ga[iC], agnes(animals, method="gave", par.meth= -0.1)[iC]),
agnes+ all.equal(aa.ga[iC], agnes(animals, method="gav", par.m= c(1.1,1.1,-0.1,0))[iC]))
agnes> ## End(Don't show)
agnes>
agnes> ## Show how "gaverage" is a "generalized average":
agnes> aa.ga.0 <- agnes(animals, method = "gaverage", par.method = 0)
agnes> stopifnot(all.equal(aa.ga.0[iC], aa.a[iC]))
