-1
A
回答
0
我會嘗試使用GGPLOT2和ggrepel包這一點。我借用代碼從this question製作凸包。
set.seed(175)
library(ggplot2)
library(ggrepel) # Or first install.packages("ggrepel")
# Make the cluster
mtcars$cluster <- as.factor(kmeans(mtcars, 3)$cluster)
# Get the convex hull for the axes you want to plot
hull_df <- plyr::ddply(mtcars, "cluster", function(dta) {
hull <- chull(dta$mpg, dta$disp)
dta[c(hull, hull[1]), ]
})
ggplot(mtcars, aes(mpg, disp, color = cluster, fill = cluster)) +
geom_point() +
geom_polygon(data = hull_df, alpha = 0.5) +
geom_text_repel(aes(label = row.names(mtcars)))
+0
謝謝,您真的幫了我很多! 如果你知道任何參考資料來解釋clusplot是如何工作的,我會非常感激,因爲對於我所尋找的,他是唯一一個可以繪製兩個以上參數的集羣,或者它只使用2個最重要的參數,運行像選擇變量的東西? PCA?! – user2905427
0
下面是一些例子如何與DBSCAN做到這一點:
library(dbscan)
set.seed(2)
n <- 400
x <- cbind(
x = runif(4, 0, 1) + rnorm(n, sd=0.1),
y = runif(4, 0, 1) + rnorm(n, sd=0.1),
z = runif(4, 0, 1) + rnorm(n, sd=0.1)
)
cl <- rep(1:4, time = 100)
### show some points (first 10) inside the hulls with text
hullplot(x, cl, main = "True clusters", pch = NA)
points(x[1:10,])
text(x[1:10,], labels = paste("Obs.", 1:10), pos = 3)
### look at dimensions x and z
hullplot(x[, c("x", "z")], cl, main = "True clusters")
### use a PCA projection
hullplot(prcomp(x)$x, cl, main = "True clusters")
你可以看一下包wordcloud更好字佈局。請參閱here.
相關問題
- 1. 聚簇索引和非聚簇索引
- 2. 按名稱查找對象
- 3. RStudio多重查看中的列表對象的名稱
- 4. 聚簇索引
- 5. mysql中的聚簇表查詢
- 6. 按名稱查找查看
- 7. 非主鍵列上的聚簇索引或非聚簇索引?
- 8. 如何執行非聚簇索引查找而不是聚簇索引掃描
- 9. 名稱對象
- 10. 如何用非聚集索引查找或聚簇索引查找替換聚簇索引掃描?
- 11. 查詢的名稱和對象在Python
- 12. 查找對象的名稱與編號
- 13. 查看對象
- 14. 具有非聚簇索引但沒有聚簇索引
- 15. 名稱空間對象的名稱
- 16. 文本文件的聚簇
- 17. 帶聚簇註釋的Mapview
- 18. 傳遞匿名對象來查看
- 19. 查看名稱消失
- 20. SETATTR(對象名稱,值)對對象.__ SETATTR __(名稱,值)
- 21. 如何檢查對象名稱?
- 22. 在NSMutableArray中按名稱查找對象
- 23. 從對象名稱
- 24. 動態LINQ(到對象):從對象名稱列表(字符串)中替換查詢中的對象名稱?
- 25. 從非聚簇更改主鍵聚集
- 26. 保存B +樹的聚簇索引和非聚簇索引的位置?
- 27. 無效的對象名稱
- 28. 對象引用的名稱
- 29. 獲取對象的名稱
- 30. 對象的屬性名稱
請添加創建劇情的代碼 – rawr