Returns a list which describes the convex hull(s) of a set of points.
Any number of nested convex hulls may be generated, including the entire set.
USAGE:
chull(x, y, peel=F, maxpeel=<<see below>>, onbdy=peel, tol=.0001)
REQUIRED ARGUMENTS:
x,y
coordinates of points. The coordinates can be given by two vector arguments or by a single arguments x which is a times series, a two-column matrix, or a list containing components named x and y.
Missing values are not accepted.
OPTIONAL ARGUMENTS:
peel
logical flag:
should successive convex hulls be peeled from
the remaining points, generating a nested set of hulls?
maxpeel
maximum number of hulls that should be peeled from the data.
The default, if
peel is
TRUE, is to peel until
all points are assigned to a hull.
If
maxpeel is given,
peel is coerced to
TRUE.
onbdy
should points on the boundary of a convex hull (but
not vertices of the hull) be included in the hull?
tol
relative tolerance for determining if a third point is sufficiently
collinear to two points in the hull to also be included in the hull.
VALUE:
if
peel is
FALSE, a vector giving the indices of the points on the hull.
If
peel is
TRUE, a list with components
depth
,
hull and
count.
depth
a vector which assigns a depth to each point, i.e., the
number of hulls surrounding the point (the outermost points are at depth
1).
Outliers will have
small values of
depth, interior points relatively large
values.
hull
vector giving indices of the points on the hull. Along with
count
, determines all of the hull peels. The first
count[1]
values of
hull determine the outermost hull,
the next
count[2] are the second hull, etc.
count
counts of the number of points on successive hulls.
REFERENCES:
Barnett, V. (1976). The ordering of multivariate data.
Journal of the Royal Statistical Society, Series A139, 318-354.
SEE ALSO:
,
.
EXAMPLES:
hull <- chull(x,y)
plot(x,y)
polygon(x[hull],y[hull],density=0) # draw hull
p <- chull(corn.rain, corn.yield, peel=T) # all hulls
which <- rep(seq(p$count), p$count) # which peel for each pt
s <- split(p$hull, which)
plot(corn.rain, corn.yield)
for(i in seq(s)) { # plot all peels
j <- s[[i]] # indices of points on ith peel
if(length(j)>2)
polygon(corn.rain[j], corn.yield[j], density=0,lty=i)
}