Learn R Programming

swfscMisc (version 1.6.5)

crossing.point: Crossing Point

Description

Return point where two lines cross

Usage

crossing.point(l1, l2)

Value

a data.frame of x and y values of points where lines cross

Arguments

l1, l2

matrices representing two lines, where first two columns are x and y values respectively

Author

Eric Archer eric.archer@noaa.gov

Examples

Run this code
x <- 1:100
line1 <- cbind(x, 3 + 3 * x)
line2 <- cbind(x, 10 - 3 * x)
plot(line1[, 1], line1[, 2], type = "l", col = "red")
lines(line2[, 1], line2[, 2], col = "blue")
cr.pt <- crossing.point(line1, line2)
print(cr.pt)

Run the code above in your browser using DataLab