R/MER.R

Defines functions MER

Documented in MER

##########################################################
#MER from a set of points#
##########################################################
#' calculates the MER of a set of numbers'
#' @title Minimum Enclosing Rectangle (MER)
#' @description 
#' Calculates the minimum enclosing rectangle (MER) from a set of points (x,y)
#' @author Justin Moat. J.Moat@kew.org
#' @param thepoints dataframe of points ie c(x,y)
#' @return list of 4 doubles = xmin,xmax,ymin,ymax
#' @examples
#' x <- runif (20,0,10)
#' y <- runif (20,0,10)
#' df <- data.frame(x,y) 
#' MER (df)
#' @export



MER <- function(thepoints){
  xmin <- min(thepoints[1])
  xmax <- max(thepoints[1])
  ymin <- min(thepoints[2])
  ymax <- max(thepoints[2])
  return(c(xmin,xmax,ymin,ymax))
}

Try the rCAT package in your browser

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

rCAT documentation built on July 8, 2020, 6:22 p.m.