Learn R Programming

specmine (version 4.0.0)

pca_screeplot: PCA scree plot

Description

Draws a scree plot showing the individual and cumulative percentage of variance explained by the principal components.

Usage

pca_screeplot(
  pca.result,
  num.pcs = NULL,
  cex.leg = 0.8,
  leg.pos = "right",
  lab.text = c("individual percent", "cumulative percent"),
  fill.col = c("blue", "red"),
  ylab = "Percentage",
  xlab = "Principal components",
  ...
)

Value

No return value; the scree plot is drawn as a side effect.

Arguments

pca.result

PCA result object inheriting from class prcomp or princomp.

num.pcs

Optional number of principal components to display. If NULL, all available components are displayed.

cex.leg

Numeric value controlling the legend text size.

leg.pos

Legend position accepted by graphics::legend().

lab.text

Character vector of length two containing the labels for the individual and cumulative variance curves.

fill.col

Character or numeric vector of length two containing the colours for the individual and cumulative variance curves.

ylab

Y-axis label.

xlab

X-axis label.

...

Additional graphical parameters passed to graphics::matplot().

Examples

Run this code
datamat <- matrix(
  rnorm(40),
  nrow = 4,
  ncol = 10,
  dimnames = list(
    paste0("feature", 1:4),
    paste0("sample", 1:10)
  )
)

dataset <- list(data = datamat)
pca.result <- pca_analysis_dataset(dataset)

pca_screeplot(
  pca.result,
  num.pcs = 4
)

Run the code above in your browser using DataLab