convex_hull | R Documentation |
Return the convex hull for a set of (x, y) points
convex_hull(x, y)
x |
a numeric vector of x coordinates, a n by 2 matrix, or anything that
can be coerced to a matrix via |
y |
a numeric vector of y coordinates, only needed if x is a numeric vector |
The convex_hull
function returns the vertices, in an anti-clockwise
order, of the convex hull encompassing the provided data. This differs from
the polygon
function as convex hull is generated automatically via
Andrew's Monotone algorithm and the polygon
function only provides the
needed angles between edges of a given set of points.
A sccm_ch
object. This is a list
with the following
elements:
a n by 2 matrix of the vertices defining the convex hull.
a matrix of the data provided
a numeric vector of the exterior angles for each of the vertices.
a numeric vector of the row indices from x
corresponding to the data values found to be the vertices of the convex
hull.
polygon
p2d
d2p
p2p
set.seed(42)
dat <- data.frame(x = rnorm(100), y = rexp(100))
ch <- convex_hull(dat)
ch
plot(ch)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.