Learn R Programming

treePlotArea (version 3.1.0)

points2equation: Get a Slope–intercept Form from a Two-point Form of an Equation

Description

Two-point from is often seen in German national forest inventory data, we want to get an equation of form y = a + bx.

Usage

points2equation(p1, p2 = c(0, 0))

Value

A named vector with intercept ["a"] and slope ["b"]. If both points have the same value for x, no function exists. Then the intercept is NA and the slope gives the value of x.

Arguments

p1

The first point (x, y).

p2

The second point (x, y).

See Also

Other geometry functions: get_intersection(), vector_length()

Examples

Run this code
points2equation(c(0, 4), c(1, 5))

Run the code above in your browser using DataLab