dfWide2segments: Convert data.frame to plotly line segment format

dfWide2segmentsR Documentation

Convert data.frame to plotly line segment format

Description

Convert data.frame to plotly line segment format

Usage

dfWide2segments(x, axes1, axes2, ...)

Arguments

x

numeric matrix of coordinates, where x,y,z coordinates are present twice per row, and whose colnames are defined by axes1 and axes2.

axes1

vector of colnames(x) corresponding to the x,y,z coordinates of the first point in a line segment. It can be of any length, but is intended for length 2 or 3.

axes2

vector of colnames(x) corresponding to the x,y,z coordinates of the second point in a line segment. It must be the same length as axes1.

...

additional parameters are ignored.

Details

Purpose is to take a data.frame containing (x,y) or (x,y,z) coordinates for two points defined on one row, and create a data.frame with 3 rows where blank coordinates are used to separate each line segment. The main benefit in using this function is that it enables vectorized line segment drawing when used with a plotting function that recognizes line breaks via empty rows, for example plotly.

Value

data.frame where every two rows represents a line segment to be drawn by plotly, followed by a blank line indicating the line ends.

See Also

Other jam spatial functions: bgaPlotly3d(), compressPolygonM(), simplifyXY(), spline3d()


jmw86069/splicejam documentation built on Nov. 4, 2024, 10:53 a.m.