In the previous recipe, we employed the k-means method to fit data into clusters. However, if there are more than two variables, it is impossible to display how data is clustered in two dimensions. Therefore, you can use a bivariate cluster plot to first reduce variables into two components, and then use components, such as axis and circle, as clusters to show how data is clustered. In this recipe, we will illustrate how to create a bivariate cluster plot.
In this recipe, we will continue to use the customer
dataset as the input data source to draw a bivariate cluster plot.
Perform the following steps to draw a bivariate cluster plot:
- Install and load the cluster package:
> install.packages("cluster")> library(cluster)
- You can then draw a bivariate cluster plot:
> clusplot(customer, fit$cluster, color=TRUE, shade=TRUE)
The bivariate clustering plot of the customer dataset
- You can also zoom into the bivariate cluster plot:
...