Compute Principal Component Analysis using prcomp() function
We use R language’s inbuilt prcomp() function, this function takes the dataset as an argument and computes the PCA. Principal Component Analysis (PCA) is a statistical procedure that uses an orthogonal transformation that converts a set of correlated variables to a set of uncorrelated variables. Doing scale=TRUE standardizes the data.
Syntax: prcomp(numeric_data, scale = TRUE)
Code:
R
# drop the species column as its character type num_iris = subset (iris, select = - c (Species) ) # compute pca pca <- prcomp (num_iris, scale = TRUE ) pca |
Output:
How To Make Scree Plot in R with ggplot2
In this article, we are going to see how can we plot a Scree plot in R Programming Language with ggplot2.
Contact Us