powered by
Plot the results from a k-means object
# S3 method for kmeans plot(x, data = NULL, class = NULL, size = 2, legend.position = c("right", "bottom", "left", "top", "none"), title = "K-Means Results", xlab = "Principal Component 1", ylab = "Principal Component 2", ...)
A ggplot object
A kmeans object.
kmeans
The data used to kit the kmeans object.
Character name of the "true" classes of the data.
Numeric size of points
Character indicating where the legend should be placed.
Title for the plot.
Label for the x-axis.
Label for the y-axis.
Not Used.
Jared P. Lander
Plots the results of k-means with color-coding for the cluster membership. If data is not provided, then just the center points are calculated.
data
kmeans fortify ggplot plot.kmeans
k1 <- kmeans(x=iris[, 1:4], centers=3) plot(k1) plot(k1, data=iris)
Run the code above in your browser using DataLab