pca_biplot | R Documentation |
Create a ggplot biplot of a prcomp obj
pca_biplot(
obj,
components = c(1, 2),
data = NULL,
threshold = 0,
reverse = NULL,
label_size = 5,
geom_point = T
)
obj |
prcomp obj |
components |
The PCs to plot, specified as a numeric vector of length 2, Default: c(1, 2) |
data |
Optional data frame with the same number of rows as that used to compute pca, Default: NULL |
threshold |
Only display variables with loadings exceeding this value, Default: 0 |
reverse |
Vector of components that will be multiplied by -1 |
label_size |
text size of the eigenvector labels, Default: 5 |
geom_point |
whether to add geom_point to plot, Default: T |
Creates a ggplot obj from a prcomp obj. Use threshold to omit variables with small loadings. Add a data frame to create a more complex ggplot. Possibly set geom_point=F to add a geom_point with custom aesthetics.
ggplot obj
## Not run:
if(interactive()){
m <- prcomp(mtcars, scale. = T)
pca_biplot(m)
pca_biplot(m, data = mtcars, geom_point=F) + geom_point(aes(size = mpg))
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.