R/weighted.median.R

Defines functions weighted.median

weighted.median <-
function(v,weights){
	weights<-weights[order(v)]
	v<-sort(v)
	sw<-sum(weights)
	return(v[which.min(abs(cumsum(weights)-0.5*sw))])
}

Try the CNprep package in your browser

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

CNprep documentation built on May 24, 2022, 5:05 p.m.