add_x_intercepts: Add x-intercepts

View source: R/rbitr_helpers.R

add_x_interceptsR Documentation

Add x-intercepts

Description

Given a data frame of x-y coordinates, find the x-intercepts of the line segments that connect neighboring pairs of points, and add the x-intercepts to the data frame.

Usage

add_x_intercepts(dataframe, x_name, y_name)

Arguments

dataframe

A 2-column data frame with numeric columns, where each row is a point in the x-y plane.

x_name

A single-element character vector with the name of the column containing the x-coordinates.

y_name

A single-element character vector with the name of the column containing the y-coordinates.

Details

The input data frame is expected to have two columns, with each row being the Cartesian coordinates of a point in the x-y plane. If the points are arranged in order of increasing x values and connected by line segments, add_x_intercepts will find the points where the segments intersect the x-axis and add those points to the data frame.

Value

A new data frame consisting of the original data frame with new rows added for each intersection with the x-axis.


dryguy/rbitr documentation built on Oct. 15, 2024, 6:18 a.m.