pca_loadings_plot: pca_loadings_plot

View source: R/other_utils.R

pca_loadings_plotR Documentation

pca_loadings_plot

Description

A lollipop plot of PCA variable loadings, as provided by prcomp, e.g., PC1, PC2, ...

Usage

pca_loadings_plot(
  obj,
  components = 1:3,
  sortby = 1,
  threshold = 0,
  reverse = NULL
)

Arguments

obj

Output of prcomp

components

A numeric vector of components to plot

sortby

Sort variables by loadings on this component (index to component vector)

threshold

Remove variables with sum(abs(loadings)) below threshold (default=0)

reverse

Vector of components that will be multiplied by -1

Value

ggplot object

Examples

m <- prcomp(mtcars, scale = T)
pca_loadings_plot(m, components = c(1,2))

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