#' Is a data point above or below a line described by a linear mathematical formula?
#'
#' This function assesses whether a given data point is above or below a stright line described by mathematical formula.
#'
#' @param point_coord A numeric vector of point coordinates on 2D plane. Following math convention point_coord[1] is the value on X axis, while point_coord[2] is the value on Y axis.
#' @param m A single numeric of the slope.
#' @param b A single numeric of the intercept.
#' @param above A boolean indicating whether to test if the point is above or below the line.
#' @export
above_Or_below_Line <- function(point_coord=NA, m=0, b=0, above=TRUE) {
# Is the first number of input 'point_coord' vector an X coordinate? Is the second number of input 'point_coord' a Y coordinate? Make sure it is the case!
y <- m*point_coord[1]+b
if(y<point_coord[2]){
out <- TRUE
}
else{
out <- FALSE
}
if(above==TRUE){
return(out)
}
else{
return(!(out))
}
print("DONE")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.