Learn R Programming

henna (version 0.3.4)

pointsToSegments: Construct a data frame of segments from a data frame of points

Description

This function constructs a data frame of segments from a data frame of points.

Usage

pointsToSegments(pointsDF, joinEnds = TRUE)

Value

A data frame of segments represented using four columns (x, y, xEnd, yEnd).

Arguments

pointsDF

A data frame with the x and y coordinates of the points. Each point must appear only once.

joinEnds

Whether to join the last point with the first one.

Examples

Run this code
pointsDF <- data.frame(x = c(1, 2, 4, 7, 10,
12, 13, 15, 16),
y = c(1, 1, 2, 3, 3, 2, 1, 2, 1))

hullIndices <- grDevices::chull(pointsDF[, 1], pointsDF[, 2])
hull <- convexHull(pointsDF, hullIndices)
pointsToSegments(hull)

Run the code above in your browser using DataLab