| ggindplot | R Documentation |
Display observations in a plane defined by two retained
principal components from rpca. Each point shows an
observation's fitted scores, allowing patterns in the selected components
to be compared across observations or supplied groups. Labels and group
ellipses can be added. The optional ggplot2 package is required.
ggindplot(
rpcaObj,
pcs = c(1, 2),
groups = NULL,
alpha = 0.6,
ellipse = TRUE,
alpha.ellipse = 0.2,
ind_labels = TRUE,
ind_labels.names = NULL
)
rpcaObj |
An object returned by |
pcs |
Integer vector of length two selecting the retained principal
components to plot, in horizontal and vertical order. The default is
|
groups |
Optional factor with one entry for each row of |
alpha |
Numeric value between zero and one controlling point
transparency, with zero fully transparent and one opaque. The default is
|
ellipse |
Logical; draw a filled data ellipse for each supplied group
when |
alpha.ellipse |
Numeric value between zero and one controlling ellipse
transparency. The default is |
ind_labels |
Logical; show a text label for each observation when
|
ind_labels.names |
Optional character vector with one label per row of
|
The horizontal and vertical coordinates are the columns of
rpcaObj$x selected by pcs. These fitted scores retain the
centering and scaling used in rpca; the plotting function does not
standardize or recompute them. For randomized fits, they are the stored
projected-SVD scores described in rpca.
Each axis label gives its component's share of rpcaObj$var, the
total variance of the processed input. Variance in omitted components
remains in the denominator, so a view of two components need not account
for all of the variation.
When groups are supplied, point colours identify group membership and
data ellipses summarize the spread of fitted scores within each group.
The ellipses use the multivariate-t model in
stat_ellipse, whose computation also requires
the recommended package MASS. They do not estimate confidence
regions for group means or test group separation. Small groups or
degenerate score distributions may not support ellipse estimation; use
ellipse = FALSE in that case.
A ggplot2 plot object. Print the object to draw the plot, or add layers, labels, and themes with ggplot2.
N. Benjamin Erichson
rpca, ggbiplot,
ggcorplot, ggscreeplot,
ggplot, stat_ellipse
if (requireNamespace("ggplot2", quietly = TRUE)) {
set.seed(42)
fit <- rpca(iris[, 1:4], k = 3)
print(ggindplot(fit, pcs = c(1, 3), groups = iris$Species,
ellipse = FALSE, ind_labels = FALSE))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.