View source: R/line.intersect.R
line.intersect | R Documentation |
Returns coordinates where pairs of lines intersect.
line.intersect(beta0, beta1, pairwise = TRUE)
beta0 |
Two-element vector or two-column matrix of line slopes and intercept values. |
beta1 |
Two-element vector or two-column matrix of line slopes and intercept values. |
pairwise |
Logical value specifying whether to calculate intersection points for all possible slope and intercept pair combinations. |
Returns a list of x and y intersection points.
n <- 10 m <- 2*runif(n)-1 b <- 2*runif(n)-1 plot(c(-2, 2), c(-2, 2), type = "n", xlab = "x", ylab = "y") for (i in 1:n) abline(b[i], m[i], col = "grey70") r <- line.intersect(cbind(m, b)) points(r$x, r$y, pch = 21, bg = "red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.