Given a set of integers of different values how do I calculate the minimum number of the largest of integers that are required, when summed, to equal 50% of the total sum of the the set?
For example, > length(myTable$lgth) [1] 303403 > sum(myTable$lgth) [1] 4735396 I know through brute force that the N50 of the following set is 42 but I don't know how to solve this without iteration > sum(myTable$lgth[which(myTable$lgth>=42)]) [1] 2374260 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.