Description Usage Arguments See Also Examples
Extract the fitted values from a data set modeled by kMeansLloyd
.
1 2 |
object |
an object of class |
method |
character: either |
... |
other arguments. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # create example data set
X <- rbind(matrix(rnorm(50, sd = 0.5), ncol = 2),
matrix(rnorm(50, mean = 1, sd = 0.5), ncol = 2))
# perform k-means algorithm
result <- kMeansLloyd(x = X, centroids = 2, nStart = 2)
# fit the result
# centroids
fitted(result, method = "centroids")
# cluster
fitted(result, method = "cluster")
# compute cluster centroids "fitted" to each observation:
fittedX <- fitted(result)
residX <- X - fittedX
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.