R/calcmode.r

Defines functions calcmode

Documented in calcmode

calcmode <- function(data,adjust=1) {
  # Function for mode estimation of a continuous variable
  # data: vector used to estimate density 
  # adjust: increase this value to make the density estimate smoother.
  
  x<-data
  hist(x,freq=FALSE)
  s<-density(x,adjust=adjust)
  ymode <- max(s$y)
  modex = s$x[which.max(s$y)]
  lines(s$x,s$y,col="red")
  points(modex,ymode,col="blue")
  modex
}

Try the MetaLandSim package in your browser

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

MetaLandSim documentation built on Jan. 13, 2023, 1:11 a.m.