# for vector
a<-rnorm(100,mean=6,sd=1)
cutoff(a,.7) #return minimum number of elements to account 70 percent of total
## The function is currently defined as
function (x, cutoff)
{
x <- x[order(-x)]
xb <- cumsum(x)
xc <- xb/sum(x, na.rm = T)
length(xc[xc < cutoff])
}
Run the code above in your browser using DataLab