在 R 中保存 Agnes 对象

Saving Agnes Object in R

抱歉,如果这真的很基本 - 有没有办法将 Agnes 对象从 R 中的 Cluster 库保存到文件中以供在另一个会话中使用?我已经查看了 CRAN pdf 以及 Whosebug 上的类似问题,但没有看到任何内容。

提前致谢。

如评论中所述:

library(cluster)

data(animals)
aa.ga <- agnes(animals, method = "gaverage")

saveRDS(aa.ga,"aa.ga.RDS") # Save it

rm(aa.ga) # Remove it so I can prove this works

aa.ga <- readRDS("aa.ga.RDS") # Read it back in

aa.ga
Call:  agnes(x = animals, method = "gaverage")  Agglomerative coefficient:  0.8285911  Order of objects:  

[1] ant lob fly her liz sal bee cpl spi cat chi man cow lio rab duc eag ele wha fro Height (summary): Min. 1st Qu. Median Mean 3rd Qu. Max. 0.0000 0.0000 1.2050 0.9573 1.5890 2.6230

Available components: [1] "order"     "height"    "ac"        "merge"  "diss"      "call"      "method"    "order.lab" "data"