easystats/see

Plotting the results of cluster analyses

lnalborczyk opened this issue · 2 comments

Hi,

thank you for developing and maintaining the package, it's immensely useful!

I get a weird error when trying to plot the results of cluster analyses conducted via parameters::cluster_analyses(). Here is a reproducible example.

set.seed(666)
df <- data.frame(a = rnorm(n = 1e2), b = rnorm(n = 1e2) )
rez <- cluster_analysis(x = df, n = 3, method = "kmeans")
plot(rez)
plot(summary(rez) )

The last line works well, but plot(rez) returns this error:

Error in names(data) <- c("x", "y") : 
  'names' attribute [2] must be the same length as the vector [1]

Do you know what happens and how to solve this?

Thank you!

Ladislas

Seems to be related to the number of variables in the data:

library(easystats)
data(iris)
result <- cluster_analysis(iris[, 1:3], n = 3)
plot(result)

data(iris)
result <- cluster_analysis(iris[, 1:2], n = 3)
plot(result)
#> Error in names(data) <- c("x", "y"): 'names' attribute [2] must be the same length as the vector [1]

I think this is closed by the referenced commit