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