Learn R Programming

specmine (version 4.0.0)

pca_scoresplot3D: PCA 3D scores plot

Description

Creates an interactive three-dimensional scores plot from a PCA result.

Usage

pca_scoresplot3D(
  dataset,
  pca.result,
  column.class = NULL,
  pcas = c(1, 2, 3),
  title = "PCA 3D Scores Plot"
)

Value

A plotly htmlwidget.

Arguments

dataset

Dataset used to calculate the PCA.

pca.result

Result returned by pca_analysis_dataset().

column.class

Optional metadata column used to colour samples.

pcas

Integer vector of length three specifying the principal components to plot.

title

Plot title.

Examples

Run this code
# \donttest{
if (requireNamespace("plotly", quietly = TRUE)) {
  datamat <- matrix(
    rnorm(40),
    nrow = 5,
    ncol = 8
  )

  dataset <- list(
    data = datamat,
    metadata = data.frame(
      class = factor(rep(c("A", "B"), length.out = 8))
    )
  )

  result <- pca_analysis_dataset(dataset)

  pca_scoresplot3D(
    dataset,
    result,
    column.class = "class",
    pcas = c(1, 2, 3)
  )
}
# }

Run the code above in your browser using DataLab