R/abline2xy.R

Defines functions abline2xy

abline2xy <- function(xrange, yrange, slope, intercept){

  x <- xrange
  y <- c(intercept + slope * x[1], intercept + slope * x[2])

  if(y[1] < yrange[1] ) {
    x[1] <- (yrange[1] - intercept)/ slope
    y[1] <- yrange[1]
  }
  if(y[2] > yrange[2]){
    x[2] <- (yrange[2] - intercept)/ slope
    y[2] <- yrange[2]
  }
  list(x = x, y = y)
}

Try the loon.ggplot package in your browser

Any scripts or data that you put into this service are public.

loon.ggplot documentation built on Nov. 13, 2022, 1:06 a.m.