Question

My data has 40+ variables and I am creating a 3 cluster model on it.

I have built a kmeans model:

teen_clusters <- kmeans(interests_z, 3). 

It works fine. It is getting an output that I can read is the issue.

When I screen print the model, it places the variables on the top (40 across) and the clusters as rows (3 deep). Very hard to read.

I want it the other way around. 3 cluster columns and 40 rows.

I have tried the below, but get the same thing. This does way too much screen wrap.

aggregate(interests_z,by=list(teen_clusters$cluster),FUN=mean)
Was it helpful?

Solution

Since we don't have your data lets use mtcars ...

ret <- kmeans(mtcars,3)

ret$centers       # the default format
t(ret$centers)    # transposed as you want

To see the components of ret use str(ret)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top