pca_biplot: pca_biplot

pca_biplotR Documentation

pca_biplot

Description

Create a ggplot biplot of a prcomp obj

Usage

pca_biplot(
  obj,
  components = c(1, 2),
  data = NULL,
  threshold = 0,
  reverse = NULL,
  label_size = 5,
  geom_point = T
)

Arguments

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

Details

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.

Value

ggplot obj

Examples

## 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)

grasshoppermouse/hagenutils documentation built on Dec. 6, 2024, 8:31 p.m.