biplot-stats {ordr} | R Documentation |
Convenience stats for row and column matrix factors
Description
These statistical transformations (stats) adapt
conventional ggplot2 stats to one or the other matrix factor
of a tbl_ord, in lieu of stat_rows()
or stat_cols()
. They
accept the same parameters as their corresponding conventional
stats.
Usage
stat_rows_ellipse(
mapping = NULL,
data = NULL,
geom = "path",
position = "identity",
...,
type = "t",
level = 0.95,
segments = 51,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
stat_cols_ellipse(
mapping = NULL,
data = NULL,
geom = "path",
position = "identity",
...,
type = "t",
level = 0.95,
segments = 51,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
stat_rows_center(
mapping = NULL,
data = NULL,
geom = "point",
position = "identity",
show.legend = NA,
inherit.aes = TRUE,
...,
fun.data = NULL,
fun.center = NULL,
fun.min = NULL,
fun.max = NULL,
fun.args = list()
)
stat_cols_center(
mapping = NULL,
data = NULL,
geom = "point",
position = "identity",
show.legend = NA,
inherit.aes = TRUE,
...,
fun.data = NULL,
fun.center = NULL,
fun.min = NULL,
fun.max = NULL,
fun.args = list()
)
stat_rows_star(
mapping = NULL,
data = NULL,
geom = "segment",
position = "identity",
show.legend = NA,
inherit.aes = TRUE,
...,
fun.data = NULL,
fun.center = NULL,
fun.args = list()
)
stat_cols_star(
mapping = NULL,
data = NULL,
geom = "segment",
position = "identity",
show.legend = NA,
inherit.aes = TRUE,
...,
fun.data = NULL,
fun.center = NULL,
fun.args = list()
)
stat_rows_chull(
mapping = NULL,
data = NULL,
geom = "polygon",
position = "identity",
show.legend = NA,
inherit.aes = TRUE,
...
)
stat_cols_chull(
mapping = NULL,
data = NULL,
geom = "polygon",
position = "identity",
show.legend = NA,
inherit.aes = TRUE,
...
)
stat_rows_cone(
mapping = NULL,
data = NULL,
geom = "path",
position = "identity",
origin = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
stat_cols_cone(
mapping = NULL,
data = NULL,
geom = "path",
position = "identity",
origin = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
stat_rows_scale(
mapping = NULL,
data = NULL,
geom = "point",
position = "identity",
show.legend = NA,
inherit.aes = TRUE,
...,
mult = 1
)
stat_cols_scale(
mapping = NULL,
data = NULL,
geom = "point",
position = "identity",
show.legend = NA,
inherit.aes = TRUE,
...,
mult = 1
)
stat_rows_spantree(
mapping = NULL,
data = NULL,
geom = "segment",
position = "identity",
engine = "mlpack",
method = "euclidean",
show.legend = NA,
inherit.aes = TRUE,
...
)
stat_cols_spantree(
mapping = NULL,
data = NULL,
geom = "segment",
position = "identity",
engine = "mlpack",
method = "euclidean",
show.legend = NA,
inherit.aes = TRUE,
...
)
Arguments
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use to display the data, either as a
|
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
... |
Additional arguments passed to |
type |
The type of ellipse.
The default |
level |
The level at which to draw an ellipse,
or, if |
segments |
The number of segments to be used in drawing the ellipse. |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
fun.data , fun.center , fun.min , fun.max , fun.args |
Functions and arguments
treated as in |
origin |
Logical; whether to include the origin with the transformed
data. Defaults to |
mult |
Numeric value used to scale the coordinates. |
engine |
A single character string specifying the package implementation
to use; |
method |
Passed to |
Value
A ggproto layer.
Ordination aesthetics
The convenience function ord_aes()
can be used to incorporate all
coordinates of the ordination model into a statistical transformation. It
maps the coordinates to the custom aesthetics ..coord1
, ..coord2
, etc.
Some transformations, e.g. stat_center()
, are commutative with projection
to the 'x' and 'y' coordinates. If they detect aesthetics of the form
..coord[0-9]+
, then ..coord1
and ..coord2
are converted to x
and y
while any remaining are ignored.
Other transformations, e.g. stat_spantree()
, yield different results in a
planar biplot when they are computer before or after projection. If such a
stat layer detects these aesthetics, then the lot of them are used in the
transformation.
In either case, the stat layer returns a data frame with position aesthetics
x
and y
.
See Also
Other biplot layers:
biplot-geoms
,
stat_rows()
Examples
# compute row-principal components of scaled iris measurements
iris[, -5] %>%
prcomp(scale = TRUE) %>%
as_tbl_ord() %>%
mutate_rows(species = iris$Species) %>%
print() -> iris_pca
# row-principal biplot with centroids and confidence elliptical disks
iris_pca %>%
ggbiplot(aes(color = species)) +
theme_bw() +
geom_rows_point() +
geom_polygon(
aes(fill = species),
color = NA, alpha = .25, stat = "rows_ellipse"
) +
geom_cols_vector(color = "#444444") +
scale_color_brewer(
type = "qual", palette = 2,
aesthetics = c("color", "fill")
) +
ggtitle(
"Row-principal PCA biplot of Anderson iris measurements",
"Overlaid with 95% confidence disks"
)