View source: R/machinelearning.R
| pca_plot_3d | R Documentation |
Draw a 3D PCA scatter plot.
pca_plot_3d(
dataset,
model,
var.class,
pcas = 1:3,
colors = NULL,
legend.place = "topright",
...
)
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 |
A 3D scatter plot of the selected principal components, drawn for its side effects.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.