R/other_functions.R

Defines functions get_y_function

get_y_function <- function(y, slope) {
  function(x) x * slope + y
}

get_x_intercept <- Vectorize(function(y, slope) {
  intercept <- (y * -1) / slope
  if (is.na(intercept)) {
    intercept <- NA_real_
  } else if (intercept == Inf) {
    intercept <- NA_real_
  }
  intercept
})
firthj/oneliners documentation built on June 29, 2022, 11:19 p.m.