The convex function returns the pairs of points that make up the edges of the convex hull, but the indices for these points need correcting for us by R. It would also be useful to return just a list of the points as well as the edges.
x = c(30,70,20,50,40,70)
y = c(35,80,70,50,60,20)
p =data.frame(x,y)
hull =convex(point=p)
hull$convexhull[is.na(hull$convexhull)] = 0
hull$convexhull = hull$convexhull + 1
nodes = unique(c(hull$convexhull[,1],hull$convexhull[,2]))
plot(p)
points(p[nodes,], col="red", pch=16)
The
convex
function returns the pairs of points that make up the edges of the convex hull, but the indices for these points need correcting for us by R. It would also be useful to return just a list of the points as well as the edges.