pca | R Documentation |
Apply PCA (Principal Component Analysis) to the data and construct a scatter plot of the first two principal components.
pca(data, groups = "none")
data |
Dataset in |
groups |
Groups to color observations and draw ellipses around each group of samples with a confidence level of 0.98. Default is "none". |
A ggplot
.
# Load the required package
library(hclusteasy)
# Read the 'iris' dataset from the package
data("iris_uci")
# Select column "Species" (groups) in the iris dataset
species <- iris_uci[, 5]
# Remove column "Species" in the iris dataset
iris <- iris_uci[, -5]
# Apply pca and ploting the two firsts components without groups
pca(iris)
# Apply pca and ploting the first two components with groups
pca(iris, groups = species)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.