##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (v, weights)
{
weights <- weights[order(v)]
v <- sort(v)
sw <- sum(weights)
return(v[order(abs(cumsum(weights) - 0.5 * sw))][1])
}Run the code above in your browser using DataLab