factoextra
factoextra copied to clipboard
fviz_cluster & pam: dissimiliarty matrix issues
Hello,
Thank you for all of your work on this package - it makes unsupervised learning fun to implement and visualise!
I am currently having issues getting the fviz_cluster()
function to properly graph the output from a "pam"
object. A quick overview of the code:
library(factorextra)
library(cluster)
## pseudo data
data -> df
## calculate distance measure - correlation based
get_dist(df, method = "spearman") -> dist_mtx
## compute analysis w/ 4 clusters
cluster::pam(x = dist_mtx, k = 4, diss = TRUE) -> pam_res
## visualise results
fviz_cluster(x = pam_res, geom = "point")
I receive an error stating, "Error in array(x, c(length(x), 1L), if (!is.null(names))) list(names(x), : 'data' must be of vector type, was NULL
"
Some people online have opted to append the original data to the "pam"
results (i.e., df -> pam_res$data
) to force a visual but I am wondering if there is a deeper issue with this fix. For instance, will appending the data is my dissimilarity matrix being ignored and the function is only using the original data - which would defeat the purpose.
+1
I am also receiving this error with the output of a fanny object from the cluster package