wrap_hull()computes convex hull of a set of observations.
wrap_hull(x, ...) stat_hull( mapping = NULL, data = NULL, geom = "polygon", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ... ) # S4 method for MultivariateAnalysis wrap_hull(x, margin = 1, axes = c(1, 2), group = NULL) # S4 method for BootstrapPCA wrap_hull(x, axes = c(1, 2))
Currently not used.
Set of aesthetic mappings created by
aes_(). If specified and
inherit.aes = TRUE(the default), it is combined with the default mapping at the top level of the plot. You must supply
mappingif there is no plot mapping.
The data to be displayed in this layer. There are three options:
NULL, the default, the data is inherited from the plot data as specified in the call to
data.frame, or other object, will override the plot data. All objects will be fortified to produce a data frame. See
fortify()for which variables will be created.
functionwill be called with a single argument, the plot data. The return value must be a
data.frame, and will be used as the layer data. A
functioncan be created from a
~ head(.x, 10)).
The geometric object to use display the data
Position adjustment, either as a string, or the result of a call to a position adjustment function.
logicalscalar: should missing values be silently removed? If
FALSE(the ), missing values are removed with a warning.
logical. Should this layer be included in the legends?
NA, the default, includes if any aesthetics are mapped.
FALSEnever includes, and
TRUEalways includes. It can also be a named logical vector to finely select the aesthetics to display.
FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g.
numericvector giving the subscript which the data will be returned:
1indicates individuals/rows (the default),
numericvector giving the dimensions to be for which to compute results.
A vector specifying the group an observation belongs to.
## Load data data("iris") ## Compute principal components analysis X <- pca(iris, scale = TRUE) #> 1 qualitative variable was removed: Species. ## Plot results plot_rows(X, colour = "group", group = iris$Species) + khroma::scale_colour_highcontrast() ## Convex hull coordinates hulls <- wrap_hull(X, group = iris$Species) head(hulls) #> F1 F2 group #> setosa.32 -1.831595 0.42369507 setosa #> setosa.24 -1.818670 0.08555853 setosa #> setosa.42 -1.858122 -2.33741516 setosa #> setosa.14 -2.633101 -0.96150673 setosa #> setosa.23 -2.774345 0.45834367 setosa #> setosa.33 -2.614948 1.79357586 setosa ## Plot with convex hulls plot_rows(X, colour = "group", group = iris$Species) + stat_hull(geom = "path") + khroma::scale_colour_highcontrast()