RPubs will retire in June 2027. Your existing documents will stay accessible through December 31, 2031
and Connect Cloud is the recommended home for new publishing. Read the blog post

Recently Published

Plot5 hierarquical clustering
require(graphics) ### Example 1: Violent crime rates by US state hc <- hclust(dist(USArrests), "ave") plot(hc) plot(hc, hang = -1) ## Do the same with centroid clustering and *squared* Euclidean distance, ## cut the tree into ten clusters and reconstruct the upper part of the ## tree from the cluster centers. hc <- hclust(dist(USArrests)^2, "cen") memb <- cutree(hc, k = 10) cent <- matrix(numeric(), 10, 4) for(k in 1:10) cent[k,] <- colMeans(USArrests[memb == k, , drop = FALSE]) hc1 <- hclust(dist(cent)^2, method = "cen", members = table(memb)) opar <- par(mfrow = c(1, 2)) plot(hc, labels = FALSE, hang = -1, main = "Original Tree") plot(hc1, labels = FALSE, hang = -1, main = "Re-start from 10 clusters") par(opar) ### Example 2: Straight-line distances among 10 US cities ## Compare the results of algorithms "ward.D" and "ward.D2" mds2 <- -cmdscale(UScitiesD) plot(mds2, type="n", axes=FALSE, ann=FALSE) text(mds2, labels=rownames(mds2), xpd = NA) hcity <- list( D.o = hclust(UScitiesD, "ward.D"), # "wrong" D2o = hclust(UScitiesD, "ward.D2"),# similar to next two D = hclust(1/2* (UScitiesD)^2, "ward.D"), # Ward(1963) ESS based D2 = hclust(sqrt(1/2)*UScitiesD, "ward.D2")) # sqrt(ESS) based opar <- par(mfrow = c(2, 2), mgp = c(1.2, .3, 0), mar = .1 + c(3,4,2,1)) plot(hcity$D.o, hang=-1, col=2) # different clustering than the others plot(hcity$D2o, hang=-1) # [1,2] plot(hcity$D, hang=-1) # [2,1] plot(hcity$D2, hang=-1) # [2,2] as above, [1,2], just y-axis numbers differ par(opar) mrg <- sapply(hcity, `[[`, "merge") # defining cluster tree (apart from height) ht <- sapply(hcity, `[[`, "height") stopifnot(exprs = { any(mrg[,2] != mrg[,1]) mrg[,2] == mrg[,3:4] # all eq., but the first all.equal(ht[,"D2" ], sqrt(ht[,"D"])) all.equal(ht[,"D2"], sqrt(1/2)*ht[,"D2o"]) }) plot(ht)
Plot6hierarquicalclustering
require(graphics) ### Example 1: Violent crime rates by US state hc <- hclust(dist(USArrests), "ave") plot(hc) plot(hc, hang = -1) ## Do the same with centroid clustering and *squared* Euclidean distance, ## cut the tree into ten clusters and reconstruct the upper part of the ## tree from the cluster centers. hc <- hclust(dist(USArrests)^2, "cen") memb <- cutree(hc, k = 10) cent <- matrix(numeric(), 10, 4) for(k in 1:10) cent[k,] <- colMeans(USArrests[memb == k, , drop = FALSE]) hc1 <- hclust(dist(cent)^2, method = "cen", members = table(memb)) opar <- par(mfrow = c(1, 2)) plot(hc, labels = FALSE, hang = -1, main = "Original Tree") plot(hc1, labels = FALSE, hang = -1, main = "Re-start from 10 clusters") par(opar) ### Example 2: Straight-line distances among 10 US cities ## Compare the results of algorithms "ward.D" and "ward.D2" mds2 <- -cmdscale(UScitiesD) plot(mds2, type="n", axes=FALSE, ann=FALSE) text(mds2, labels=rownames(mds2), xpd = NA) hcity <- list( D.o = hclust(UScitiesD, "ward.D"), # "wrong" D2o = hclust(UScitiesD, "ward.D2"),# similar to next two D = hclust(1/2* (UScitiesD)^2, "ward.D"), # Ward(1963) ESS based D2 = hclust(sqrt(1/2)*UScitiesD, "ward.D2")) # sqrt(ESS) based opar <- par(mfrow = c(2, 2), mgp = c(1.2, .3, 0), mar = .1 + c(3,4,2,1)) plot(hcity$D.o, hang=-1, col=2) # different clustering than the others plot(hcity$D2o, hang=-1) # [1,2] plot(hcity$D, hang=-1) # [2,1] plot(hcity$D2, hang=-1) # [2,2] as above, [1,2], just y-axis numbers differ par(opar) mrg <- sapply(hcity, `[[`, "merge") # defining cluster tree (apart from height) ht <- sapply(hcity, `[[`, "height") stopifnot(exprs = { any(mrg[,2] != mrg[,1]) mrg[,2] == mrg[,3:4] # all eq., but the first all.equal(ht[,"D2" ], sqrt(ht[,"D"])) all.equal(ht[,"D2"], sqrt(1/2)*ht[,"D2o"]) }) plot(ht)
Bluesky scrapes
sim6.2
ANALISIS KLASTER NEGARA BERDASARKAN INDIKATOR PENDUKUNG KEBAHAGIAAN MENGGUNAKAN METODE K-MEANS
Analisis pengelompokan negara berdasarkan indikator pendukung kebahagiaan yang meliputi kontribusi PDB per kapita, dukungan sosial, dan harapan hidup sehat menggunakan metode K-Means berdasarkan data World Happiness Report 2025.
Document
Document