pca_plot_3d: Auto-exported function: pca_plot_3d

View source: R/machinelearning.R

pca_plot_3dR Documentation

Auto-exported function: pca_plot_3d

Description

Draw a 3D PCA scatter plot.

Usage

pca_plot_3d(
  dataset,
  model,
  var.class,
  pcas = 1:3,
  colors = NULL,
  legend.place = "topright",
  ...
)

Arguments

dataset

A dataset object containing metadata.

model

A PCA result object containing component scores.

var.class

The metadata variable used to define classes.

pcas

A length-3 integer vector indicating which principal components to plot.

colors

Optional vector of colors used for the classes.

legend.place

Position of the legend.

...

Additional arguments passed to legend().

Value

A 3D scatter plot of the selected principal components, drawn for its side effects.

Examples

## Not run: 
datamat <- matrix(
  rnorm(24),
  nrow = 4,
  dimnames = list(paste0("v", 1:4), paste0("s", 1:6))
)
metadata <- data.frame(class = factor(c("A", "A", "A", "B", "B", "B")))
dataset <- list(data = datamat, metadata = metadata)
pca_model <- list(scores = prcomp(t(datamat))$x)
pca_plot_3d(dataset, pca_model, "class")

## End(Not run)

specmine documentation built on Aug. 5, 2026, 5:06 p.m.