powered by
Creates a customizable scree plot based on a `prcomp` object showing variance explained by each component.
spec_pca_screeplot( pca, n = 10, show_labels = TRUE, show_cumulative = TRUE, bar_color = "steelblue", line_color = "darkred", show_kaiser = FALSE, title = "Scree Plot", subtitle = NULL, accuracy = 1 )
A ggplot2 scree plot object.
A PCA object returned by [prcomp()].
Number of components to display. Defaults to 10.
Logical. Show percentage labels on bars? Default is TRUE.
Logical. Show cumulative variance line? Default is TRUE.
Fill color for bars. Default is "steelblue".
Color of the cumulative line and points. Default is "darkred".
Logical. Show Kaiser criterion line? Default is FALSE.
Plot title. Default is "Scree Plot".
Optional plot subtitle.
Number of decimal places for variance percentages. Default is 1.
pca <- prcomp(USArrests, scale. = TRUE) spec_pca_screeplot(pca, n = 4) spec_pca_screeplot(pca, show_kaiser = TRUE, bar_color = "darkblue")
Run the code above in your browser using DataLab