Reputation: 7121
I am working with binomial data (belongs to two classes). Here's what the data looks like:
df <-data.frame(matrix(runif(10*100), ncol=10))
group <- c(rep("A",50),rep("B",50))
df <- cbind(df,group)
plot(df$X1,df$X2,col=df$group)
I know it is possible to do Kmeans clustering for principal components of the dataset. But I am trying to cluster the data based on the two variables X1 and X2 and assign the found cluster to each datapoint. Is that possible to do? I am happy with any suggested clustering method.
Thank you,
Upvotes: 2
Views: 3072
Reputation: 66834
You can just put those two variables into kmeans
:
plot(df[,1:2],col=kmeans(df[,1:2],2)$cluster)
Upvotes: 3