R/kmeansMask.R

kmeansMask<-function(x){
  resamp<-quantile(x,probs = seq(0,1,length.out = 1000))
  mod<-kmeans(resamp,2)
  thresh<-resamp[which.max(abs(diff(mod$cluster)))]
  mask<-ifelse(x<=thresh,0,1)
  return(mask)
}

Try the FIACH package in your browser

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

FIACH documentation built on May 1, 2019, 8:02 p.m.