| plot.rpca | R Documentation |
Summarize an object returned by rpca with
plots of retained variance and of variables and observations in a
component plane. A scree plot shows how much variation the fit captures;
factor maps display the corresponding directions and fitted scores.
## S3 method for class 'rpca'
plot(x, ...)
x |
An object returned by |
... |
Named arguments for |
The function draws the available plots in sequence on the
active graphics device. The scree plot shows the variance captured by
the retained components. With at least two components, a variable factor
map then shows their directions in the selected plane. An individual
factor map follows when fitted observation scores are available from
retx = TRUE. A fit with one retained component therefore produces
only a scree plot; a fit with at least two components and
retx = FALSE produces the scree and variable factor plots.
Factor maps use components one and two by default. Supply pcs to
inspect another pair of retained components. Any observation groups or
labels must correspond to the fitted score rows, after incomplete training
observations have been omitted. The ggplot2 package must be
installed. Call the plotting helpers directly when a particular plot is
needed for further customization or saving.
The last ggplot2 plot drawn, returned invisibly. This is the individual factor map when available, otherwise the variable factor map or the scree plot.
N. Benjamin Erichson
rpca, ggscreeplot,
ggcorplot, ggindplot,
ggbiplot.
if (requireNamespace("ggplot2", quietly = TRUE)) {
set.seed(42)
fit <- rpca(iris[, 1:4], k = 2)
last_plot <- plot(fit, type = "ratio", pcs = c(1, 2),
groups = iris$Species, ind_labels = FALSE,
ellipse = FALSE)
# Request a single plot directly for further customization or saving.
scree <- ggscreeplot(fit, type = "cum")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.